Class: Dvi::Opcode::RuleBase

Inherits:
Base
  • Object
show all
Defined in:
lib/dvi/opcode.rb

Overview

RuleBase is a base class for SetRule/PutRule opcodes.

Direct Known Subclasses

PutRule, SetRule

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

range, set_range

Constructor Details

#initialize(height, width) ⇒ RuleBase

Returns a new instance of RuleBase.



97
98
99
100
101
102
103
104
105
# File 'lib/dvi/opcode.rb', line 97

def initialize(height, width)
  unless (-2147483648..2147483647).include?(height) and
      (-2147483648..2147483647).include?(width)
    raise ArgumentError
  end

  @height = height
  @width = width
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



95
96
97
# File 'lib/dvi/opcode.rb', line 95

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



95
96
97
# File 'lib/dvi/opcode.rb', line 95

def width
  @width
end

Class Method Details

.read(cmd, io) ⇒ Object



107
108
109
# File 'lib/dvi/opcode.rb', line 107

def self.read(cmd, io)
  return self.new(io.read_int4, io.read_int4)
end

Instance Method Details

#interpret(ps) ⇒ Object



111
112
113
114
115
116
# File 'lib/dvi/opcode.rb', line 111

def interpret(ps)
  # append a new rule.
  ps.rules << rule = Dvi::Rule.new(ps.h, ps.v, @height, @width)
  # change the current position.
  ps.h += @width unless self.kind_of?(PutRule)
end