Class: Viberator::Event

Inherits:
Record
  • Object
show all
Defined in:
lib/viberator/event.rb

Instance Method Summary collapse

Methods inherited from Record

#initialize

Constructor Details

This class inherits a constructor from Viberator::Record

Instance Method Details

#authorObject



10
11
12
# File 'lib/viberator/event.rb', line 10

def author
  @db.author @attrs[:Number]
end

#imageObject



31
32
33
34
# File 'lib/viberator/event.rb', line 31

def image
  return @db.sticker @attrs[:StickerID] if sticker?
  return payload_path                   if photo?
end

#image_thumbObject



36
37
38
# File 'lib/viberator/event.rb', line 36

def image_thumb
  return thumbnail_path if photo?
end

#message?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/viberator/event.rb', line 14

def message?
  !@attrs[:Body].to_s.empty?
end

#photo?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/viberator/event.rb', line 18

def photo?
  !@attrs[:PayloadPath].to_s.empty?
end

#sticker?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/viberator/event.rb', line 22

def sticker?
  0 < @attrs[:StickerID].to_i
end

#textObject



26
27
28
29
# File 'lib/viberator/event.rb', line 26

def text
  return @attrs[:Body]    if message?
  return @attrs[:Subject] if photo?
end

#timestampObject



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

def timestamp
  Time.at @attrs[:TimeStamp]
end