class Botomizer::Message

Attributes

cmd[RW]
data[RW]
id[RW]
text[RW]

Public Class Methods

new(params, options = {}) click to toggle source
# 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

Public Instance Methods

cmd?() click to toggle source
# File lib/botomizer/message.rb, line 20
def cmd?
  !@cmd.nil?
end
data?() click to toggle source
# File lib/botomizer/message.rb, line 28
def data?
  !@data.blank?
end
text?() click to toggle source
# File lib/botomizer/message.rb, line 24
def text?
  !@text.blank?
end