Class: OpenWire::InboundMessage
- Inherits:
-
Object
- Object
- OpenWire::InboundMessage
- Defined in:
- lib/open_wire/envelope.rb
Overview
Parsed open-wire/1 inbound envelope.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#from_id ⇒ Object
readonly
Returns the value of attribute from_id.
-
#from_kind ⇒ Object
readonly
Returns the value of attribute from_kind.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#installation_id ⇒ Object
readonly
Returns the value of attribute installation_id.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#thread_id ⇒ Object
readonly
Returns the value of attribute thread_id.
-
#to_id ⇒ Object
readonly
Returns the value of attribute to_id.
-
#to_kind ⇒ Object
readonly
Returns the value of attribute to_kind.
Instance Method Summary collapse
- #dm? ⇒ Boolean
-
#initialize(payload) ⇒ InboundMessage
constructor
A new instance of InboundMessage.
- #protocol ⇒ Object
- #to_h ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(payload) ⇒ InboundMessage
Returns a new instance of InboundMessage.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/open_wire/envelope.rb', line 9 def initialize(payload) @raw = payload.is_a?(Hash) ? payload : {} @id = @raw["id"] @channel = @raw["channel"] @installation_id = @raw["installation_id"] @created_at = @raw["created_at"] thread = @raw["thread"] || {} @thread_id = thread["id"] from = @raw["from"] || {} @from_id = from["id"] @from_kind = from["kind"] to = @raw["to"] || {} @to_id = to["id"] @to_kind = to["kind"] @body = @raw["body"] || {} @text = (@body["text"] || "").to_s end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/open_wire/envelope.rb', line 6 def body @body end |
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
6 7 8 |
# File 'lib/open_wire/envelope.rb', line 6 def channel @channel end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
6 7 8 |
# File 'lib/open_wire/envelope.rb', line 6 def created_at @created_at end |
#from_id ⇒ Object (readonly)
Returns the value of attribute from_id.
6 7 8 |
# File 'lib/open_wire/envelope.rb', line 6 def from_id @from_id end |
#from_kind ⇒ Object (readonly)
Returns the value of attribute from_kind.
6 7 8 |
# File 'lib/open_wire/envelope.rb', line 6 def from_kind @from_kind end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/open_wire/envelope.rb', line 6 def id @id end |
#installation_id ⇒ Object (readonly)
Returns the value of attribute installation_id.
6 7 8 |
# File 'lib/open_wire/envelope.rb', line 6 def installation_id @installation_id end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
6 7 8 |
# File 'lib/open_wire/envelope.rb', line 6 def raw @raw end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
6 7 8 |
# File 'lib/open_wire/envelope.rb', line 6 def text @text end |
#thread_id ⇒ Object (readonly)
Returns the value of attribute thread_id.
6 7 8 |
# File 'lib/open_wire/envelope.rb', line 6 def thread_id @thread_id end |
#to_id ⇒ Object (readonly)
Returns the value of attribute to_id.
6 7 8 |
# File 'lib/open_wire/envelope.rb', line 6 def to_id @to_id end |
#to_kind ⇒ Object (readonly)
Returns the value of attribute to_kind.
6 7 8 |
# File 'lib/open_wire/envelope.rb', line 6 def to_kind @to_kind end |
Instance Method Details
#dm? ⇒ Boolean
27 28 29 |
# File 'lib/open_wire/envelope.rb', line 27 def dm? to_kind.to_s == "dm" end |
#protocol ⇒ Object
31 32 33 |
# File 'lib/open_wire/envelope.rb', line 31 def protocol @raw["protocol"] end |
#to_h ⇒ Object
39 40 41 |
# File 'lib/open_wire/envelope.rb', line 39 def to_h @raw end |
#type ⇒ Object
35 36 37 |
# File 'lib/open_wire/envelope.rb', line 35 def type @raw["type"] end |