Class: EventsJp::EventObject
- Inherits:
-
Object
- Object
- EventsJp::EventObject
- Extended by:
- Connection
- Defined in:
- lib/events_jp/event_object/event_object.rb
Direct Known Subclasses
Defined Under Namespace
Classes: ImplementationException
Class Method Summary collapse
- .finish_get?(res, current, limit = nil) ⇒ Boolean
- .merged_option(keyword, response, option) ⇒ Object
- .parse_datetime(dt) ⇒ Object
- .service_name ⇒ Object
- .to_basic_hash(h) ⇒ Object
Methods included from Connection
Class Method Details
.finish_get?(res, current, limit = nil) ⇒ Boolean
17 18 19 20 21 |
# File 'lib/events_jp/event_object/event_object.rb', line 17 def finish_get?(res, current, limit = nil) return true if limit.to_i > 0 && res.count >= limit return true if current.count == 0 return false end |
.merged_option(keyword, response, option) ⇒ Object
11 12 13 14 15 |
# File 'lib/events_jp/event_object/event_object.rb', line 11 def merged_option(keyword, response, option) opt = option.dup opt.merge!({start: (response.count + 1)}) keyword ? opt.merge!(keyword: keyword) : opt end |
.parse_datetime(dt) ⇒ Object
41 42 43 |
# File 'lib/events_jp/event_object/event_object.rb', line 41 def parse_datetime(dt) dt ? DateTime.parse(dt) : nil end |
.service_name ⇒ Object
7 8 9 |
# File 'lib/events_jp/event_object/event_object.rb', line 7 def service_name self.name.to_s.downcase.gsub(/^(.*::)/, '') end |
.to_basic_hash(h) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/events_jp/event_object/event_object.rb', line 23 def to_basic_hash(h) Hashie::Mash.new({ service: service_name, address: h[:address], catch: h[:catch], title: h[:title], event_url: h[:event_url], started_at: parse_datetime(h[:started_at]), ended_at: parse_datetime(h[:ended_at]), place: h[:place], lon: h[:lon].to_f, lat: h[:lat].to_f, limit: h[:limit], accepted: h[:accepted], waiting: h[:waiting] }) end |