Class: Line::Bot::Receive::Operation
- Inherits:
-
Object
- Object
- Line::Bot::Receive::Operation
- Defined in:
- lib/line/bot/receive/operation.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#event_type ⇒ Object
readonly
Returns the value of attribute event_type.
-
#from_channel_id ⇒ Object
readonly
Returns the value of attribute from_channel_id.
-
#from_mid ⇒ Object
readonly
Returns the value of attribute from_mid.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#to_channel_id ⇒ Object
readonly
Returns the value of attribute to_channel_id.
-
#to_mid ⇒ Object
readonly
Returns the value of attribute to_mid.
Instance Method Summary collapse
- #create_content(attrs) ⇒ Object
-
#initialize(env) ⇒ Operation
constructor
A new instance of Operation.
Constructor Details
#initialize(env) ⇒ Operation
Returns a new instance of Operation.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/line/bot/receive/operation.rb', line 9 def initialize(env) @id = env['content']['id'] @from_mid = env['content']['from'] @to_mid = env['content']['to'] @from_channel_id = env['fromChannel'] @to_channel_id = env['toChannel'] @event_type = env['eventType'] @content = create_content(env['content']) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/line/bot/receive/operation.rb', line 7 def content @content end |
#event_type ⇒ Object (readonly)
Returns the value of attribute event_type.
7 8 9 |
# File 'lib/line/bot/receive/operation.rb', line 7 def event_type @event_type end |
#from_channel_id ⇒ Object (readonly)
Returns the value of attribute from_channel_id.
7 8 9 |
# File 'lib/line/bot/receive/operation.rb', line 7 def from_channel_id @from_channel_id end |
#from_mid ⇒ Object (readonly)
Returns the value of attribute from_mid.
7 8 9 |
# File 'lib/line/bot/receive/operation.rb', line 7 def from_mid @from_mid end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/line/bot/receive/operation.rb', line 7 def id @id end |
#to_channel_id ⇒ Object (readonly)
Returns the value of attribute to_channel_id.
7 8 9 |
# File 'lib/line/bot/receive/operation.rb', line 7 def to_channel_id @to_channel_id end |
#to_mid ⇒ Object (readonly)
Returns the value of attribute to_mid.
7 8 9 |
# File 'lib/line/bot/receive/operation.rb', line 7 def to_mid @to_mid end |
Instance Method Details
#create_content(attrs) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/line/bot/receive/operation.rb', line 21 def create_content(attrs) case attrs['opType'] when Line::Bot::Operation::OpType::ADD_FRIEND return Line::Bot::Operation::AddFriend.new( revision: attrs['revision'], op_type: attrs['opType'], params: attrs['params'], ) when Line::Bot::Operation::OpType::BLOCK_ACCOUNT return Line::Bot::Operation::BlockAccount.new( revision: attrs['revision'], op_type: attrs['opType'], params: attrs['params'], ) else end end |