Class: RTunnel::SendDataCommand
Constant Summary collapse
- RE =
%r{^([^|]+)\|([^|]+)\|}
Constants inherited from Command
Command::CLASSES_TO_CODES, Command::CODES_TO_CLASSES
Instance Attribute Summary collapse
-
#conn_id ⇒ Object
readonly
Returns the value of attribute conn_id.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(conn_id, data) ⇒ SendDataCommand
constructor
A new instance of SendDataCommand.
- #to_s ⇒ Object
Constructor Details
#initialize(conn_id, data) ⇒ SendDataCommand
Returns a new instance of SendDataCommand.
76 77 78 79 |
# File 'lib/cmds.rb', line 76 def initialize(conn_id, data) @conn_id = conn_id @data = data end |
Instance Attribute Details
#conn_id ⇒ Object (readonly)
Returns the value of attribute conn_id.
73 74 75 |
# File 'lib/cmds.rb', line 73 def conn_id @conn_id end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
74 75 76 |
# File 'lib/cmds.rb', line 74 def data @data end |
Class Method Details
.match(data) ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/cmds.rb', line 104 def match(data) return false if ! (data =~ RE) data_size = $2.to_i data.sub(RE, '').size >= data_size end |
.parse(data) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/cmds.rb', line 88 def parse(data) data =~ RE conn_id = $1 data_size = $2.to_i new_data = data.sub(RE, '') cmd_data = new_data[0,data_size] cmd = SendDataCommand.new(conn_id, cmd_data) data.replace(new_data[data_size..-1]) cmd end |
Instance Method Details
#to_s ⇒ Object
81 82 83 |
# File 'lib/cmds.rb', line 81 def to_s super + "#{conn_id}|#{data.size}|#{data}" end |