SamanthaToet / yelpr

R client for working with Yelp's Fusion API
Other
2 stars 1 forks source link

Option to disable map on printing #13

Open malcolmbarrett opened 4 years ago

malcolmbarrett commented 4 years ago

It might be nice to let users specify whether or not to print the map. We could use an option, e.g. options(yelpr.show_map = FALSE). Then, the print method would look something like this, where show_map = getOption("yelpr.show_map") is an argument that gets checked before printing the map:

print.business_tbl <- function(x, ..., view = interactive(), show_map = getOption("yelpr.show_map")) {
      # not totally sure about this condition. `getOption()` returns `NULL` if nothing is set.
      if (isTRUE(show_map) || is.null(show_map)) {
            # ...code to print leaflet map
       }

       NextMethod()
}

If we add this, we should probably document it in yelp_search() since most people don't look at print() method documentation.

SamanthaToet commented 4 years ago

Oh that's perfect! I spent the last week trying to rewrite yelp_search so that if print = TRUE it would print the map, but this is a much more succinct way.