Class: Dvi::Opcode::Pre
Overview
Pre is a class for preamble opcode.
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#den ⇒ Object
readonly
Returns the value of attribute den.
-
#mag ⇒ Object
readonly
Returns the value of attribute mag.
-
#num ⇒ Object
readonly
Returns the value of attribute num.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(version, num, den, mag, comment) ⇒ Pre
constructor
A new instance of Pre.
- #interpret(ps) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(version, num, den, mag, comment) ⇒ Pre
Returns a new instance of Pre.
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
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
427 428 429 |
# File 'lib/dvi/opcode.rb', line 427 def comment @comment end |
#den ⇒ Object (readonly)
Returns the value of attribute den.
427 428 429 |
# File 'lib/dvi/opcode.rb', line 427 def den @den end |
#mag ⇒ Object (readonly)
Returns the value of attribute mag.
427 428 429 |
# File 'lib/dvi/opcode.rb', line 427 def mag @mag end |
#num ⇒ Object (readonly)
Returns the value of attribute num.
427 428 429 |
# File 'lib/dvi/opcode.rb', line 427 def num @num end |
#version ⇒ Object (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 |