Class: ChatScript::Message
- Inherits:
-
Object
- Object
- ChatScript::Message
- Defined in:
- lib/chatscript.rb
Overview
Instance Attribute Summary collapse
-
#oob ⇒ Object
Returns the value of attribute oob.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #command? ⇒ Boolean
-
#initialize(text = '', oob: '') ⇒ Message
constructor
A new instance of Message.
- #to_str ⇒ Object
Constructor Details
#initialize(text = '', oob: '') ⇒ Message
Returns a new instance of Message.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/chatscript.rb', line 13 def initialize(text = '', oob: '') if text.match(/\[.*\]/).nil? # no oob inside txt @text = text.strip @oob = oob else # split oob from txt @oob, @text = text.match(/\[(.*)\](.*)/).captures # remove any blanks @text.strip! @oob.strip! end end |
Instance Attribute Details
#oob ⇒ Object
Returns the value of attribute oob.
11 12 13 |
# File 'lib/chatscript.rb', line 11 def oob @oob end |
#text ⇒ Object
Returns the value of attribute text.
11 12 13 |
# File 'lib/chatscript.rb', line 11 def text @text end |
Instance Method Details
#command? ⇒ Boolean
28 29 30 |
# File 'lib/chatscript.rb', line 28 def command? @text.start_with? ':' end |
#to_str ⇒ Object
32 33 34 |
# File 'lib/chatscript.rb', line 32 def to_str @oob.empty? ? @text : "[ #@oob ] #@text" end |