Class: MonogotoApi::Event::List

Inherits:
Object
  • Object
show all
Defined in:
lib/monogoto_api/event/list.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeList

Returns a new instance of List.



8
9
10
# File 'lib/monogoto_api/event/list.rb', line 8

def initialize
    @events = []
end

Instance Attribute Details

#counterObject (readonly)

Returns the value of attribute counter.



6
7
8
# File 'lib/monogoto_api/event/list.rb', line 6

def counter
  @counter
end

#eventsObject (readonly)

Returns the value of attribute events.



6
7
8
# File 'lib/monogoto_api/event/list.rb', line 6

def events
  @events
end

Class Method Details

.parse(resp_events) ⇒ Object

Parser of API events response



20
21
22
23
24
# File 'lib/monogoto_api/event/list.rb', line 20

def self.parse(resp_events)
    list = new
    resp_events.fetch("hits", {}).each { |event| list.push(MonogotoApi::Event.parse(event)) }
    list
end

Instance Method Details

#push(event) ⇒ Object

Push event element to events array



13
14
15
16
17
# File 'lib/monogoto_api/event/list.rb', line 13

def push(event)
    push_result = @events.push(event)
    @counter = push_result.size
    push_result
end