Class: Origami::FDF::Header
- Inherits:
-
Object
- Object
- Origami::FDF::Header
- Defined in:
- lib/origami/extensions/fdf.rb
Constant Summary collapse
- MAGIC =
/%FDF-(?<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 = 2) ⇒ Header
constructor
Creates a file header, with the given major and minor versions.
-
#to_f ⇒ Object
:nodoc:.
- #to_s ⇒ Object
-
#to_sym ⇒ Object
:nodoc:.
Constructor Details
#initialize(major_version = 1, minor_version = 2) ⇒ Header
Creates a file header, with the given major and minor versions.
- major_version
-
Major version.
- minor_version
-
Minor version.
57 58 59 |
# File 'lib/origami/extensions/fdf.rb', line 57 def initialize(major_version = 1, minor_version = 2) @major_version, @minor_version = major_version, minor_version end |
Instance Attribute Details
#major_version ⇒ Object
Returns the value of attribute major_version.
50 51 52 |
# File 'lib/origami/extensions/fdf.rb', line 50 def major_version @major_version end |
#minor_version ⇒ Object
Returns the value of attribute minor_version.
50 51 52 |
# File 'lib/origami/extensions/fdf.rb', line 50 def minor_version @minor_version end |
Class Method Details
.parse(stream) ⇒ Object
:nodoc:
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/origami/extensions/fdf.rb', line 61 def self.parse(stream) #:nodoc: if not stream.scan(MAGIC).nil? maj = stream['major'].to_i min = stream['minor'].to_i else raise InvalidHeader, "Invalid header format" end stream.skip(REGEXP_WHITESPACES) FDF::Header.new(maj, min) end |
Instance Method Details
#to_f ⇒ Object
:nodoc:
82 83 84 |
# File 'lib/origami/extensions/fdf.rb', line 82 def to_f #:nodoc: to_sym.to_s.to_f end |
#to_s ⇒ Object
74 75 76 |
# File 'lib/origami/extensions/fdf.rb', line 74 def to_s "%FDF-#{@major_version}.#{@minor_version}".b + EOL end |
#to_sym ⇒ Object
:nodoc:
78 79 80 |
# File 'lib/origami/extensions/fdf.rb', line 78 def to_sym #:nodoc: "#{@major_version}.#{@minor_version}".to_sym end |