Class: MessageFactory::Handlers::Ping
- Defined in:
- lib/messagefactory/handlers/PING.rb
Instance Method Summary collapse
-
#process(string) ⇒ Object
- string
-
string to process Create a new Ping message OpenStruct will contain: #type #direction #raw #received #server #message :nodoc: PING :not.configured :nodoc: :not.configured PING :test.
- #types_process ⇒ Object
Instance Method Details
#process(string) ⇒ Object
- string
-
string to process
Create a new Ping message OpenStruct will contain: #type #direction #raw #received #server #message :nodoc: PING :not.configured :nodoc: :not.configured PING :test
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/messagefactory/handlers/PING.rb', line 16 def process(string) string = string.dup m = mk_struct(string) begin m.type = :ping if(string.slice(0).chr == ':') string.slice!(0) m.server = string.slice!(0, string.index(' ')) string.slice!(0) raise 'error' unless string.slice!(0, string.index(' ')).to_sym == :PING string.slice!(0, string.index(':')+1) m. = string else raise 'error' unless string.slice!(0, string.index(' ')).to_sym == :PING string.slice!(0, string.index(':')+1) m.server = string m. = string end rescue raise "Failed to parse Ping message: #{m.raw}" end m end |
#types_process ⇒ Object
7 8 9 |
# File 'lib/messagefactory/handlers/PING.rb', line 7 def types_process :PING end |