Class: Skypekit::FFI::Event

Inherits:
FFI::ManagedStruct
  • Object
show all
Defined in:
lib/skypekit/ffi/event.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.release(pointer) ⇒ Object



7
8
9
# File 'lib/skypekit/ffi/event.rb', line 7

def self.release(pointer)
  FFI.skypekit_event_free(pointer)
end

Instance Method Details

#created_atObject



25
26
27
# File 'lib/skypekit/ffi/event.rb', line 25

def created_at
  @created_at ||= Time.at(self[:timestamp])
end

#dataObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/skypekit/ffi/event.rb', line 29

def data
  @data ||= 
    case self.type
    when :account_status
      AccountStatusData.new(self[:data])
    when :chat_message
      ChatMessageData.new(self[:data])
    else
      raise NotImplementedError, "event type #{type.inspect} is not implemeted"
    end
end

#inspectObject



41
42
43
# File 'lib/skypekit/ffi/event.rb', line 41

def inspect
  "#{super} type=#{type} created_at=#{created_at}"
end

#timestampObject



21
22
23
# File 'lib/skypekit/ffi/event.rb', line 21

def timestamp
  self[:timestamp]
end

#typeObject



17
18
19
# File 'lib/skypekit/ffi/event.rb', line 17

def type
  self[:type]
end