Class: RTunnel::ConnectionCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/cmds.rb

Constant Summary collapse

RE =
%r{^([^|]+)\|}

Constants inherited from Command

RTunnel::Command::CLASSES_TO_CODES, RTunnel::Command::CODES_TO_CLASSES

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conn_id) ⇒ ConnectionCommand

Returns a new instance of ConnectionCommand.



37
38
39
# File 'lib/cmds.rb', line 37

def initialize(conn_id)
  @conn_id = conn_id
end

Instance Attribute Details

#conn_idObject (readonly)

Returns the value of attribute conn_id.



35
36
37
# File 'lib/cmds.rb', line 35

def conn_id
  @conn_id
end

Class Method Details

.match(data) ⇒ Object



59
60
61
# File 'lib/cmds.rb', line 59

def match(data)
  !! (data =~ RE)
end

.parse(data) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/cmds.rb', line 48

def parse(data)
  data =~ RE
  conn_id = $1

  cmd = self.new(conn_id)

  data.sub! RE, ''

  cmd
end

Instance Method Details

#to_sObject



41
42
43
# File 'lib/cmds.rb', line 41

def to_s
  super + "#{conn_id}|"
end