Method: Osm::Section#get_notepad

Defined in:
lib/osm/section.rb

#get_notepad(api, options = {}) ⇒ String

Get the section’s notepad from OSM

Parameters:

  • api (Osm::Api)

    The api to use to make the request

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :no_cache (Boolean) — default: optional

    if true then the data will be retreived from OSM not the cache

Returns:

  • (String)

    the section’s notepad



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/osm/section.rb', line 300

def get_notepad(api, options={})
  require_access_to_section(api, self, options)
  cache_key = ['notepad', id]

  if !options[:no_cache] && cache_exist?(api, cache_key) && can_access_section?(api, self.id)
    return cache_read(api, cache_key)
  end

  notepads = api.perform_query('api.php?action=getNotepads')
  return '' unless notepads.is_a?(Hash)

  notepad = ''
  notepads.each do |key, value|
    cache_write(api, ['notepad', key.to_i], value)
    notepad = value if key.to_i == id
  end

  return notepad
end