Class: OTerm::Telnet

Inherits:
Object
  • Object
show all
Defined in:
lib/oterm/telnet.rb

Constant Summary collapse

IAC =
255.chr
WILL =

verbs

251.chr
WONT =
252.chr
DO =
253.chr
DONT =
254.chr
BIN =

features

0.chr
ECHO =
1.chr
SGA =

one character at a time

3.chr

Class Method Summary collapse

Class Method Details

.msg(verb, feature) ⇒ Object



18
19
20
# File 'lib/oterm/telnet.rb', line 18

def self.msg(verb, feature)
  [IAC, verb, feature].join('')
end

.parse(line) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/oterm/telnet.rb', line 22

def self.parse(line)
  msgs = []
  v = nil
  line.each_char do |c|
    if nil == v
      v = c unless IAC == c
    else
      msgs << [v, c]
      v = nil
    end
  end
  msgs
end