class TSparser::AribStringDecoder::Decoder::ControlCodeProcessor

Inner class to process control code(bytes).

Public Class Methods

new(control_code_map, decoded) click to toggle source
# File lib/arib_string_decoder.rb, line 295
def initialize(control_code_map, decoded)
  @control_code_map = control_code_map
  @decoded = decoded
end

Public Instance Methods

exec(arg_num, proc) click to toggle source
# File lib/arib_string_decoder.rb, line 330
def exec(arg_num, proc)
  args = []
  arg_num.times{ args << read_one }
  instance_exec(*args, &proc)
end
get(byte) click to toggle source
# File lib/arib_string_decoder.rb, line 304
def get(byte)
  if @control_code_map[:C0].match?(byte)
    return @control_code_map[:C0].get(byte)
  elsif @control_code_map[:C1].match?(byte)
    return @control_code_map[:C1].get(byte)
  else
    raise "Undefined code #{byte}."
  end
end
match?(byte) click to toggle source
# File lib/arib_string_decoder.rb, line 300
def match?(byte)
  return @control_code_map[:C0].match?(byte) || @control_code_map[:C1].match?(byte)
end
nothing() click to toggle source
# File lib/arib_string_decoder.rb, line 336
def nothing
end
process(byte, binary) click to toggle source
# File lib/arib_string_decoder.rb, line 314
def process(byte, binary)
  operation_name, args = get(byte)
  @binary = binary
  send(operation_name, *args)
  @binary = nil
end
putstr(str) click to toggle source
# File lib/arib_string_decoder.rb, line 321
def putstr(str)
  @decoded.push_str(str)
end
read_one() click to toggle source
# File lib/arib_string_decoder.rb, line 325
def read_one
  raise "Binary is not found." unless @binary
  return @binary.read_byte_as_integer(1)
end