Class: Textecho::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/textecho/base.rb

Direct Known Subclasses

Multimessage, Randgen, Timecheck

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#input_messageObject

Returns the value of attribute input_message.



6
7
8
# File 'lib/textecho/base.rb', line 6

def input_message
  @input_message
end

#localeObject

Returns the value of attribute locale.



6
7
8
# File 'lib/textecho/base.rb', line 6

def locale
  @locale
end

#msg_sourceObject

Returns the value of attribute msg_source.



6
7
8
# File 'lib/textecho/base.rb', line 6

def msg_source
  @msg_source
end

#output_listObject

Returns the value of attribute output_list.



6
7
8
# File 'lib/textecho/base.rb', line 6

def output_list
  @output_list
end

#output_messageObject

Returns the value of attribute output_message.



6
7
8
# File 'lib/textecho/base.rb', line 6

def output_message
  @output_message
end

#paramsObject

Returns the value of attribute params.



6
7
8
# File 'lib/textecho/base.rb', line 6

def params
  @params
end

#shortcodeObject

Returns the value of attribute shortcode.



6
7
8
# File 'lib/textecho/base.rb', line 6

def shortcode
  @shortcode
end

Instance Method Details

#add_msg(msg) ⇒ Object

@@host= ‘localhost:8083’



39
40
41
42
# File 'lib/textecho/base.rb', line 39

def add_msg(msg)
  self.output_message=msg   #update to latest
  self.output_list << msg
end

#debugObject



7
8
9
# File 'lib/textecho/base.rb', line 7

def debug
  false
end

#disabled_message(locale = nil) ⇒ Object



13
14
15
# File 'lib/textecho/base.rb', line 13

def disabled_message(locale=nil)
  ["Sorry this application (#{self.class.to_s}) is not enabled currently. Please try again later"]
end

#handle_message(src, msg, shortcode, locale = nil, params = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/textecho/base.rb', line 28

def handle_message(src, msg, shortcode,locale=nil,params={})
  setup
  self.locale=locale
  self.msg_source=src
  self.shortcode=shortcode
  self.input_message=msg.downcase
  self.params=params.clone
  puts "inspect is #{self.inspect} " if debug
  process()
end

#help(resp) ⇒ Object



23
24
25
26
27
# File 'lib/textecho/base.rb', line 23

def help(resp)
  raise "help response needs to be hash" if !resp.is_a? Hash
  self.locale="en" if !resp.keys.include? self.locale   # set locale to english if not proper
  return  self.help_prefix + resp[self.locale]
end

#help_prefixObject



20
21
22
# File 'lib/textecho/base.rb', line 20

def help_prefix
  "Help Message: "
end

#msgsObject



10
11
12
# File 'lib/textecho/base.rb', line 10

def msgs
  self.output_list
end

#processObject



43
44
45
46
47
48
# File 'lib/textecho/base.rb', line 43

def process()
    self.output_message="[#{self.input_message}] from #{self.msg_source} rcvd on #{self.shortcode}"
    puts "outbound message is "+ self.output_message if debug
    self.add_msg(self.output_message)
    self.output_list  #should return arrayge of mesages
end

#setupObject



17
18
19
# File 'lib/textecho/base.rb', line 17

def setup
  self.output_list = []
end