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
14
15
16
17
18
# File 'lib/botomizer/message.rb', line 4

def initialize(params, options = {})
  @id   = params[:id]
  @text = params[:text].to_s
  @data = params[:data].to_s

  if @text.index('/') == 0
    sp    = @text.gsub(options[:name] || '', '').split(' ')
    @cmd  = sp.first.downcase.gsub!('/', '')
    @text = sp.drop(1).join(' ')
  elsif @data.index('/') == 0
    sp    = @data.gsub(options[:name] || '', '').split(' ')
    @cmd  = sp.first.downcase.gsub!('/', '')
    @data = 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

#dataObject

Returns the value of attribute data.



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

def data
  @data
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)


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

def cmd?
  !@cmd.nil?
end

#data?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/botomizer/message.rb', line 28

def data?
  !@data.blank?
end

#text?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/botomizer/message.rb', line 24

def text?
  !@text.blank?
end