Class: BinData::Line

Inherits:
BasePrimitive show all
Defined in:
lib/binproxy/bd_util.rb

Overview

class BinData::Base def real_inspect "#<#selfself.class:#selfself.object_id #do |v| "#{v=#{ tmp = self.instance_variable_get v if tmp.respond_to? :real_inspect tmp.real_inspect else tmp.inspect end }" end.join ' '}>" end end

Instance Method Summary collapse

Methods inherited from BasePrimitive

#annotated_snapshot

Instance Method Details

#read_and_return_value(io) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/binproxy/bd_util.rb', line 31

def read_and_return_value(io)
  ch = nil
  str = ''
  loop do
    ch = io.readbytes(1)
    if ch == "\n"
      break
    elsif ch == "\r"
      ch = io.readbytes(1)
      io.raw_io.ungetbyte(ch) unless ch == "\n"
      break
    end
    str << ch
  end
  str
end

#sensible_defaultObject



23
# File 'lib/binproxy/bd_util.rb', line 23

def sensible_default; ""; end

#value_to_binary_string(v) ⇒ Object

XXX not sure if this does the right thing wrt non-ascii input can you slip CR or LF in via other encodings?



27
28
29
# File 'lib/binproxy/bd_util.rb', line 27

def value_to_binary_string(v)
  v.to_s.chomp.dup.force_encoding('BINARY').chomp + eval_parameter(:line_end)
end