Class: Botomizer::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/botomizer/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @id   = params[:id]
  @text = params[:text].to_s

  if @text.index('/') == 0
    sp    = @text.gsub(options[:name] || '', '').split(' ')
    @cmd  = sp.first.downcase.gsub!('/', '')
    @text = sp.drop(1).join(' ')
  end
end

Instance Attribute Details

#cmdObject

Returns the value of attribute cmd.



2
3
4
# File 'lib/botomizer/message.rb', line 2

def cmd
  @cmd
end

#idObject

Returns the value of attribute id.



2
3
4
# File 'lib/botomizer/message.rb', line 2

def id
  @id
end

#textObject

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

Returns:

  • (Boolean)


15
16
17
# File 'lib/botomizer/message.rb', line 15

def cmd?
  !@cmd.nil?
end

#text?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/botomizer/message.rb', line 19

def text?
  !@text.blank?
end