Class: Chatroid::Adapter::Twitter::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/chatroid/adapter/twitter/event.rb

Constant Summary collapse

TYPES =
%w[
  favorite
  unfavorite
  follow
  unfollow
  list_member_added
  list_member_removed
  list_user_subscribed
  list_user_unsubscribed
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json, user_id) ⇒ Event

Returns a new instance of Event.



20
21
22
23
# File 'lib/chatroid/adapter/twitter/event.rb', line 20

def initialize(json, user_id)
  @params  = JSON.parse(json)
  @user_id = user_id
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



18
19
20
# File 'lib/chatroid/adapter/twitter/event.rb', line 18

def params
  @params
end

Instance Method Details

#typeObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/chatroid/adapter/twitter/event.rb', line 25

def type
  if has_event_type? && targeted_to_me?
    @params["event"]
  elsif reply_to_me?
    "reply"
  elsif tweet?
    "tweet"
  elsif favorite?
    "favorite_other"
  else
    "unknown"
  end
end