Sha256: ce20a4bbfad8d0cf432183431013b6a4310fb3e6d058f2c30f0d6d6ae33195ed

Contents?: true

Size: 575 Bytes

Versions: 2

Compression:

Stored size: 575 Bytes

Contents

module GoogleAnalytics
  class EventCollection
    include Enumerable
    
    class InvalidEventError < StandardError
      def initialize(non_event)
        super("EventCollection#<< expects instances of Event, you passed #{non_event}")
      end
    end
    
    def initialize
      @events = []
    end
    
    def <<(event)
      raise InvalidEventError.new(event) unless event.is_a?(Event)

      @events << event
    end

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

    def length
      @events.length
    end
    alias_method :size, :length

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
google-analytics-rails-0.0.3 lib/google-analytics/events/event_collection.rb
google-analytics-rails-0.0.2 lib/google-analytics/events/event_collection.rb