Class: Attentive::Message
- Inherits:
-
Object
- Object
- Attentive::Message
- Defined in:
- lib/attentive/message.rb
Instance Attribute Summary collapse
-
#contexts ⇒ Object
readonly
Returns the value of attribute contexts.
-
#original_message ⇒ Object
readonly
Returns the value of attribute original_message.
-
#text ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(original_message, params = {}) ⇒ Message
constructor
A new instance of Message.
- #inspect ⇒ Object
- #length ⇒ Object
- #tokens ⇒ Object
Constructor Details
#initialize(original_message, params = {}) ⇒ Message
Returns a new instance of Message.
8 9 10 11 12 13 14 |
# File 'lib/attentive/message.rb', line 8 def initialize(, params={}) @original_message = @text = .to_s @contexts = Set.new(params.fetch(:contexts, [])) @contexts << :conversation if tokens.grep(Attentive::Tokens::Invocation).any? @contexts += Array(.contexts) if .respond_to?(:contexts) end |
Instance Attribute Details
#contexts ⇒ Object (readonly)
Returns the value of attribute contexts.
6 7 8 |
# File 'lib/attentive/message.rb', line 6 def contexts @contexts end |
#original_message ⇒ Object (readonly)
Returns the value of attribute original_message.
6 7 8 |
# File 'lib/attentive/message.rb', line 6 def @original_message end |
#text ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute text.
6 7 8 |
# File 'lib/attentive/message.rb', line 6 def text @text end |
Instance Method Details
#[](key) ⇒ Object
20 21 22 |
# File 'lib/attentive/message.rb', line 20 def [](key) tokens[key] end |
#[]=(key, value) ⇒ Object
24 25 26 |
# File 'lib/attentive/message.rb', line 24 def []=(key, value) tokens[key] = value end |
#inspect ⇒ Object
34 35 36 |
# File 'lib/attentive/message.rb', line 34 def inspect tokens.inspect end |
#length ⇒ Object
28 29 30 |
# File 'lib/attentive/message.rb', line 28 def length tokens.length end |