Class: StompMessage::Options

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

Class Method Summary collapse

Class Method Details

.parse_options(params) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/stomp_message/message.rb', line 13

def self.parse_options(params)
  opts = OptionParser.new
    #   puts "argv are #{params}"
  temp_hash = {}
  temp_hash[:ack]= 'false'   # no ack by default
  temp_hash[:msisdn] = 'not_defined'
  email_flag=false
   opts.on("-h","--host VAL", String) {|val|  temp_hash[:host ] = val
                                         #  puts "host is #{val}"
                                           }
 # takes ruby hash code and converts to yaml
  opts.on("-H","--body_hash VAL", String) {|val|   temp=eval(val)
                                            temp_hash[:body ] = temp.to_yaml
                                                                                   #  puts "host is #{val}"
                                                                                     }                                          
   opts.on("-D","--email VAL", String) {|val|  temp_hash[:email ] = val
                                                temp_hash[:destination]=val }

 opts.on("-p","--port VAL", String) {|val|  temp_hash[:port ] = val      }
 opts.on("-c","--count VAL", String) {|val|  temp_hash[:count ] = val      }
 opts.on("-r","--repeat VAL", String) {|val|  temp_hash[:repeat ] = val      }
     opts.on("-S","--subject VAL", String) {|val|  temp_hash[:subject ] = val }
   opts.on("-s","--source VAL", String) {|val|  temp_hash[:source ] = val  }
     opts.on("-A","--ack VAL", String) {|val|  temp_hash[:ack ] = val
                                               temp_hash[:action]=val
                                         #     puts "ack is #{val}"
                                                         }                                                  

  opts.on("-u","--user VAL", String) {|val|  temp_hash[:user ] = val }
                                       #   puts "user is #{val}"
    opts.on("-T","--topic VAL", String) {|val|  temp_hash[:topic ] = val }                                      
  opts.on("-t","--text VAL", String) {|val|  temp_hash[:text ] = val }
                                   
 opts.on("-M","--msg_command VAL", String) {|val|  temp_hash[:command ] = val }
                                        
  opts.on("-b","--body VAL", String) {|val|  temp_hash[:body ] = val }
   opts.on("-k","--keyword VAL", String) {|val|  temp_hash[:keyword ] = val
                                           puts "keyword is #{val}"
                                           keyword_flag=false }
   opts.on("-m","--msisdn VAL", String) {|val|  temp_hash[:msisdn ] = val }
  opts.on("-U","--url VAL", String) {|val|  temp_hash[:url ] = val }
  #oops couldnot thinkof another acronym for a
  opts.on("-a","--account VAL", String) {|val|      temp_hash[:account ] = val }

 opts.on("-B","--broadcast VAL", String) {|val|  temp_hash[:broadcast ] = val        }
    opts.on("-x","--help", "get help") { |val|  temp_hash[:help]=true  }  
  opts.on("-v","--value VAL", String) {|val|  temp_hash[:value ] = val }
                                                                                                                                                 
  opts.on("-d","--debug", "turn on debug") { |val| temp_hash[:debug ] = true              }                          
                                        
                                  
  opts.parse(params)
                # puts " in HTTP #{hostname} port #{port} url: #{url}"
 
 return temp_hash

end