Class: GoogleAnalytics::EventCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/google-analytics/events/event_collection.rb

Defined Under Namespace

Classes: InvalidEventError

Instance Method Summary collapse

Constructor Details

#initializeEventCollection

Returns a new instance of EventCollection.



13
14
15
# File 'lib/google-analytics/events/event_collection.rb', line 13

def initialize
  @events = []
end

Instance Method Details

#<<(event) ⇒ Object

Raises:



17
18
19
20
21
# File 'lib/google-analytics/events/event_collection.rb', line 17

def <<(event)
  raise InvalidEventError.new(event) unless event.is_a?(Event) || event.is_a?(SingleEvent)

  @events << event
end

#eachObject



23
24
25
# File 'lib/google-analytics/events/event_collection.rb', line 23

def each
  @events.each { |e| yield e }
end

#lengthObject Also known as: size



27
28
29
# File 'lib/google-analytics/events/event_collection.rb', line 27

def length
  @events.length
end