Class: Dvi::Opcode::SetChar

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

Overview

SetChar is a class for set_char_0 … set_char_127 opcodes.

Direct Known Subclasses

SetPutBase

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

range, set_range

Constructor Details

#initialize(index) ⇒ SetChar

index

character index

Raises:

  • (ArgumentError)


36
37
38
39
# File 'lib/dvi/opcode.rb', line 36

def initialize(index)
  raise ArgumentError unless 0 <= index && index < 256
  @index = index
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



33
34
35
# File 'lib/dvi/opcode.rb', line 33

def index
  @index
end

Class Method Details

.read(cmd, io) ⇒ Object

:nodoc:



41
42
43
# File 'lib/dvi/opcode.rb', line 41

def self.read(cmd, io) #:nodoc:
  return self.new(cmd)
end

Instance Method Details

#interpret(ps) ⇒ Object

Appends a character and changes the current position.



46
47
48
49
50
51
52
53
# File 'lib/dvi/opcode.rb', line 46

def interpret(ps)
  # append a new character
  ps.chars << char = Dvi::TypesetCharacter.new(@index, ps.h, ps.v, ps.font)
  # change the current position
  unless self.kind_of?(Put)
    ps.h += ps.font.design_size * char.metric.width
  end
end