class Url2Event::Meetup
Public Class Methods
is_parser_for?(uri)
click to toggle source
# File lib/url_2_event/adapters/meetup.rb, line 6 def is_parser_for?(uri) !uri.hostname.match(%r{(?:www\.)?meetup\.com}).nil? end
Protected Instance Methods
event_endpoint()
click to toggle source
# File lib/url_2_event/adapters/meetup.rb, line 22 def event_endpoint "/2/event/#{get_id}" end
get_id()
click to toggle source
Parses the event identifier out of @uri
# File lib/url_2_event/adapters/meetup.rb, line 27 def get_id matcher = %r{/(\d+)/?$} matches = matcher.match(@uri.path) if !matches.nil? matches.captures[0] else raise Url2Event::UnparsableSourceError end end
options()
click to toggle source
# File lib/url_2_event/adapters/meetup.rb, line 13 def options @options = { query: { key: ENV['MEETUP_API_KEY'], format: 'json' } } end
to_event(response)
click to toggle source
# File lib/url_2_event/adapters/meetup.rb, line 37 def to_event(response) response['duration'] ||= 10800000 # Default of 3 hours if response['venue'] location = response['venue']['name'] location += ", " + response['venue']['address_1'] if response['venue']['address_1'] location += " " + response['venue']['address_2'] if response['venue']['address_2'] location += " " + response['venue']['address_3'] if response['venue']['address_3'] location += ", " + response['venue']['city'] if response['venue']['city'] end description = sanitize(response['description']) link = response['event_url'] if response['fee'] price = response['fee']['amount'].to_s if response['fee']['amount'] price += " " + response['fee']['currency'] if response['fee']['currency'] end if response['time'] begin_at = Time.at((response['time'] + response['utc_offset']) / 1000) end_at = Time.at((response['time'] + response['duration'] + response['utc_offset']) / 1000) end Event.new({ title: response['name'], begin_at: begin_at, end_at: end_at, location: location, description: description, price: price, link: link }) end