Sha256: b9233fb9b595d833842d39d5556599f42d81b19b2164ad1332337f6748ed5987

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

module PlaylyfeClient
  module V2
    class Event
      attr_reader :event, :timestamp, :game 
      
      def created_at
        @timestamp
      end  
      
      private 
          
        def initialize(ev_hash,game)
          @event=ev_hash[:event] || ev_hash["event"]
          ts=ev_hash[:timestamp] || ev_hash["timestamp"]
          @timestamp= (ts.kind_of?(Time) ? ts : Time.parse(ts) )
          @game=game
          @ev_hash=ev_hash
        end    
  
    end  
  end
end  

require_relative "./event/player_event.rb"
require_relative "./event/team_event.rb"
require_relative "./event/process_event.rb"


module PlaylyfeClient
  module V2
    class Event
   
      def self.build(ev_hash, game, team_player_or_process=nil)   
        event= PlaylyfeClient::V2::PlayerEvent::Base.build(ev_hash,game,team_player_or_process)
        event= PlaylyfeClient::V2::TeamEvent::Base.build(ev_hash,game,team_player_or_process) if event.nil?
        event= PlaylyfeClient::V2::ProcessEvent::Base.build(ev_hash,game,team_player_or_process) if event.nil?
        return event #could be nil!
      end    
    end  
  end
end  

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
playlyfe_client-1.1.6 lib/playlyfe_client/v2/event.rb
playlyfe_client-1.1.5 lib/playlyfe_client/v2/event.rb
playlyfe_client-1.1.3 lib/playlyfe_client/v2/event.rb
playlyfe_client-1.1.2 lib/playlyfe_client/v2/event.rb
playlyfe_client-1.1.1 lib/playlyfe_client/v2/event.rb
playlyfe_client-1.1.0 lib/playlyfe_client/v2/event.rb