Method: Osm::Event.get

Defined in:
lib/osm/event.rb

.get(api, section, event_id, options = {}) ⇒ Osm::Event?

Get an event

Parameters:

  • api (Osm::Api)

    The api to use to make the request

  • section (Osm::Section, Fixnum, #to_i)

    The section (or its ID) to get the events for

  • event_id (Fixnum, #to_i)

    The id of the event to get

Returns:

  • (Osm::Event, nil)

    the event (or nil if it couldn’t be found



189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/osm/event.rb', line 189

def self.get(api, section, event_id, options={})
  require_ability_to(api, :read, :events, section, options)
  section_id = section.to_i
  event_id = event_id.to_i
  cache_key = ['event', event_id]

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

  event_data = api.perform_query("events.php?action=getEvent&sectionid=#{section_id}&eventid=#{event_id}")
  return self.new_event_from_data(event_data)
end