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