Class: RBus::Auth::Command
- Inherits:
-
Object
- Object
- RBus::Auth::Command
- Defined in:
- lib/rbus/auth/state_machine.rb
Overview
Parses server response and splits it into component parts Decodes where appropriate (only DATA)
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #hex_decode(encoded) ⇒ Object
-
#initialize(string) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(string) ⇒ Command
Returns a new instance of Command.
158 159 160 161 |
# File 'lib/rbus/auth/state_machine.rb', line 158 def initialize(string) @command, data = string.split(/ /, 2) @data = (@command == 'DATA') ? hex_decode(data) : data end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
157 158 159 |
# File 'lib/rbus/auth/state_machine.rb', line 157 def command @command end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
157 158 159 |
# File 'lib/rbus/auth/state_machine.rb', line 157 def data @data end |
Instance Method Details
#hex_decode(encoded) ⇒ Object
163 164 165 |
# File 'lib/rbus/auth/state_machine.rb', line 163 def hex_decode(encoded) encoded.scan(/[[:xdigit:]]{2}/).map{|h|h.hex.chr}.join end |