Class: Origami::PDF::Header
- Inherits:
-
Object
- Object
- Origami::PDF::Header
- Defined in:
- lib/origami/header.rb
Overview
Class representing a PDF Header.
Constant Summary collapse
- MAGIC =
/%PDF-(?<major>\d+)\.(?<minor>\d+)/
Instance Attribute Summary collapse
-
#major_version ⇒ Object
Returns the value of attribute major_version.
-
#minor_version ⇒ Object
Returns the value of attribute minor_version.
Class Method Summary collapse
-
.parse(stream) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#initialize(major_version = 1, minor_version = 4) ⇒ Header
constructor
Creates a file header, with the given major and minor versions.
-
#to_f ⇒ Object
:nodoc:.
-
#to_s ⇒ Object
Outputs self into PDF code.
-
#to_sym ⇒ Object
:nodoc:.
Constructor Details
#initialize(major_version = 1, minor_version = 4) ⇒ Header
Creates a file header, with the given major and minor versions.
- major_version
-
Major PDF version, must be 1.
- minor_version
-
Minor PDF version, must be between 0 and 7.
41 42 43 |
# File 'lib/origami/header.rb', line 41 def initialize(major_version = 1, minor_version = 4) @major_version, @minor_version = major_version, minor_version end |
Instance Attribute Details
#major_version ⇒ Object
Returns the value of attribute major_version.
34 35 36 |
# File 'lib/origami/header.rb', line 34 def major_version @major_version end |
#minor_version ⇒ Object
Returns the value of attribute minor_version.
34 35 36 |
# File 'lib/origami/header.rb', line 34 def minor_version @minor_version end |
Class Method Details
.parse(stream) ⇒ Object
:nodoc:
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/origami/header.rb', line 45 def self.parse(stream) #:nodoc: unless stream.scan(MAGIC).nil? maj = stream['major'].to_i min = stream['minor'].to_i else raise InvalidHeaderError, "Invalid header format : #{stream.peek(15).inspect}" end stream.skip(REGEXP_WHITESPACES) PDF::Header.new(maj, min) end |
Instance Method Details
#to_f ⇒ Object
:nodoc:
69 70 71 |
# File 'lib/origami/header.rb', line 69 def to_f #:nodoc: to_sym.to_s.to_f end |
#to_s ⇒ Object
Outputs self into PDF code.
61 62 63 |
# File 'lib/origami/header.rb', line 61 def to_s "%PDF-#{@major_version}.#{@minor_version}".b + EOL end |
#to_sym ⇒ Object
:nodoc:
65 66 67 |
# File 'lib/origami/header.rb', line 65 def to_sym #:nodoc: "#{@major_version}.#{@minor_version}".to_sym end |