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(eol: $/) ⇒ 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.
55 56 57 |
# File 'lib/origami/extensions/fdf.rb', line 55 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.
48 49 50 |
# File 'lib/origami/extensions/fdf.rb', line 48 def major_version @major_version end |
#minor_version ⇒ Object
Returns the value of attribute minor_version.
48 49 50 |
# File 'lib/origami/extensions/fdf.rb', line 48 def minor_version @minor_version end |
Class Method Details
.parse(stream) ⇒ Object
:nodoc:
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/origami/extensions/fdf.rb', line 59 def self.parse(stream) # :nodoc: scanner = Parser.init_scanner(stream) if !scanner.scan(MAGIC).nil? maj = scanner['major'].to_i min = scanner['minor'].to_i else raise InvalidHeader, "Invalid header format" end scanner.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(eol: $/) ⇒ Object
74 75 76 |
# File 'lib/origami/extensions/fdf.rb', line 74 def to_s(eol: $/) "%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}" end |