Class: Dvi::Opcode::Pre

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

Overview

Pre is a class for preamble opcode.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

range, set_range

Constructor Details

#initialize(version, num, den, mag, comment) ⇒ Pre

Returns a new instance of Pre.

Raises:

  • (ArgumentError)


429
430
431
432
433
434
435
436
# File 'lib/dvi/opcode.rb', line 429

def initialize(version, num, den, mag, comment)
  raise ArgumentError unless num > 0 && den > 0 && mag > 0
  @version = version # maybe version is 2
  @num = num         # maybe 25400000 = 254cm
  @den = den         # maybe 473628672 = 7227*(2**16)
  @mag = mag         # mag / 1000
  @comment = comment # not interpreted
end

Instance Attribute Details

#commentObject (readonly)

Returns the value of attribute comment.



427
428
429
# File 'lib/dvi/opcode.rb', line 427

def comment
  @comment
end

#denObject (readonly)

Returns the value of attribute den.



427
428
429
# File 'lib/dvi/opcode.rb', line 427

def den
  @den
end

#magObject (readonly)

Returns the value of attribute mag.



427
428
429
# File 'lib/dvi/opcode.rb', line 427

def mag
  @mag
end

#numObject (readonly)

Returns the value of attribute num.



427
428
429
# File 'lib/dvi/opcode.rb', line 427

def num
  @num
end

#versionObject (readonly)

Returns the value of attribute version.



427
428
429
# File 'lib/dvi/opcode.rb', line 427

def version
  @version
end

Class Method Details

.read(cmd, io) ⇒ Object



438
439
440
441
442
443
444
445
446
# File 'lib/dvi/opcode.rb', line 438

def self.read(cmd, io)
  version = io.read_uint1
  num = io.read_uint4
  den = io.read_uint4
  mag = io.read_uint4
  size = io.read_uint1
  comment = io.read(size)
  return self.new(version, num, den, mag, comment)
end

Instance Method Details

#interpret(ps) ⇒ Object



448
449
450
451
452
453
# File 'lib/dvi/opcode.rb', line 448

def interpret(ps)
  ps.dvi_version = @version
  ps.numerator = @num
  ps.denominator = @den
  ps.mag = @mag
end