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.
-
#data ⇒ Object
Returns the value of attribute data.
-
#id ⇒ Object
Returns the value of attribute id.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #cmd? ⇒ Boolean
- #data? ⇒ 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 14 15 16 17 18 |
# File 'lib/botomizer/message.rb', line 4 def initialize(params, = {}) @id = params[:id] @text = params[:text].to_s @data = params[:data].to_s if @text.index('/') == 0 sp = @text.gsub([:name] || '', '').split(' ') @cmd = sp.first.downcase.gsub!('/', '') @text = sp.drop(1).join(' ') elsif @data.index('/') == 0 sp = @data.gsub([:name] || '', '').split(' ') @cmd = sp.first.downcase.gsub!('/', '') @data = 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 |
#data ⇒ Object
Returns the value of attribute data.
2 3 4 |
# File 'lib/botomizer/message.rb', line 2 def data @data 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
20 21 22 |
# File 'lib/botomizer/message.rb', line 20 def cmd? !@cmd.nil? end |
#data? ⇒ Boolean
28 29 30 |
# File 'lib/botomizer/message.rb', line 28 def data? !@data.blank? end |
#text? ⇒ Boolean
24 25 26 |
# File 'lib/botomizer/message.rb', line 24 def text? !@text.blank? end |