Class: Dvi::Opcode::SetPutBase

Inherits:
SetChar show all
Defined in:
lib/dvi/opcode.rb

Overview

PrintChar is a base class for set/put opcodes.

Direct Known Subclasses

Put, Set

Instance Attribute Summary

Attributes inherited from SetChar

#index

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SetChar

#interpret

Methods inherited from Base

#interpret, range, set_range

Constructor Details

#initialize(index, n) ⇒ SetPutBase

index

character index

n

read byte length



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/dvi/opcode.rb', line 61

def initialize(index, n)
  if case n
     when 1; 0 <= index && index < 256
     when 2; 0 <= index && index < 65536
     when 3; 0 <= index && index < 16777216
     when 4; -2147483648 <= index && index < 2147483648
     end
  then
    @index = index
  else
    raise ArgumentError, [index, n]
  end
end

Class Method Details

.read(cmd, io) ⇒ Object

:nodoc:



75
76
77
78
79
80
# File 'lib/dvi/opcode.rb', line 75

def self.read(cmd, io) #:nodoc:
  base = if self == Set then 127 else 132 end
  n = cmd - base
  f = if n < 4 then "read_uint" + n.to_s else "read_int4" end
  return self.new(io.__send__(f), n)
end