Class: Line::Bot::Event

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Event

Returns a new instance of Event.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/line/bot/event.rb', line 7

def initialize(options = {})
  options.each do |key, value|
    instance_variable_set("@#{key}", value)
  end

  @id ||= @data['id']
  @from_mid ||= @data['from']
  @to_mid ||= @data['to']

  @content = parse_content
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



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

def content
  @content
end

#event_typeObject (readonly)

Returns the value of attribute event_type.



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

def event_type
  @event_type
end

#from_channel_idObject (readonly)

Returns the value of attribute from_channel_id.



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

def from_channel_id
  @from_channel_id
end

#from_midObject (readonly)

Returns the value of attribute from_mid.



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

def from_mid
  @from_mid
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#to_channel_idObject (readonly)

Returns the value of attribute to_channel_id.



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

def to_channel_id
  @to_channel_id
end

#to_midObject (readonly)

Returns the value of attribute to_mid.



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

def to_mid
  @to_mid
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/line/bot/event.rb', line 19

def valid?
  !@event_type.nil? && !@content.nil?
end