Class: HipTail::Event

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

Direct Known Subclasses

RoomMessaging, RoomTopicChange, RoomVisiting

Defined Under Namespace

Classes: RoomEnter, RoomExit, RoomMessage, RoomMessaging, RoomNotification, RoomTopicChange, RoomVisiting

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ HipTail::Event



9
10
11
# File 'lib/hiptail/event.rb', line 9

def initialize(params)
  @raw = params.dup
end

Instance Attribute Details

#authorityObject

Returns the value of attribute authority.



5
6
7
# File 'lib/hiptail/event.rb', line 5

def authority
  @authority
end

#oauth_client_idString (readonly)

Returns:

  • (String)


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

def oauth_client_id
  @raw['oauth_client_id']
end

#rawObject (readonly)

Returns the value of attribute raw.



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

def raw
  @raw
end

#typeString (readonly)

Returns:

  • (String)


15
16
17
# File 'lib/hiptail/event.rb', line 15

def type
  @raw['event']
end

#webhook_idString (readonly)

Returns:

  • (String)


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

def webhook_id
  @raw['webhook_id']
end

Class Method Details

.parse(params) ⇒ HipTail::Event

Parameters:

  • params (Hash)

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/hiptail/event.rb', line 34

def parse(params)
  type = params['event']

  case params['event']
  when 'room_message'
    return Event::RoomMessage.new(params)
  when 'room_notification'
    return Event::RoomNotification.new(params)
  when 'room_topic_change'
    return Event::RoomTopicChange.new(params)
  when 'room_enter'
    return Event::RoomEnter.new(params)
  when 'room_exit'
    return Event::RoomExit.new(params)
  else
    return Event.new(params)
  end
end