Class: Botomizer::Message
- Inherits:
-
Object
- Object
- Botomizer::Message
- Defined in:
- lib/botomizer/message.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#id ⇒ Object
Returns the value of attribute id.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #cmd? ⇒ Boolean
-
#initialize(params, options = {}) ⇒ Message
constructor
A new instance of Message.
- #text? ⇒ Boolean
Constructor Details
#initialize(params, options = {}) ⇒ Message
Returns a new instance of Message.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/botomizer/message.rb', line 4 def initialize(params, = {}) @id = params[:id] @text = params[:text].to_s if @text.index('/') == 0 sp = @text.gsub([:name] || '', '').split(' ') @cmd = sp.first.downcase.gsub!('/', '') @text = sp.drop(1).join(' ') end end |
Instance Attribute Details
#cmd ⇒ Object
Returns the value of attribute cmd.
2 3 4 |
# File 'lib/botomizer/message.rb', line 2 def cmd @cmd end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/botomizer/message.rb', line 2 def id @id end |
#text ⇒ Object
Returns the value of attribute text.
2 3 4 |
# File 'lib/botomizer/message.rb', line 2 def text @text end |
Instance Method Details
#cmd? ⇒ Boolean
15 16 17 |
# File 'lib/botomizer/message.rb', line 15 def cmd? !@cmd.nil? end |
#text? ⇒ Boolean
19 20 21 |
# File 'lib/botomizer/message.rb', line 19 def text? !@text.blank? end |