Class: Origami::PPKLite::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/origami/extensions/ppklite.rb

Overview

Class representing a certificate store header.

Constant Summary collapse

MAGIC =
/%PPKLITE-(?<major>\d)\.(?<minor>\d)/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(major_version = 2, minor_version = 1) ⇒ Header

Creates a file header, with the given major and minor versions.

major_version

Major version.

minor_version

Minor version.



64
65
66
# File 'lib/origami/extensions/ppklite.rb', line 64

def initialize(major_version = 2, minor_version = 1)
    @major_version, @minor_version = major_version, minor_version
end

Instance Attribute Details

#major_versionObject

Returns the value of attribute major_version.



57
58
59
# File 'lib/origami/extensions/ppklite.rb', line 57

def major_version
  @major_version
end

#minor_versionObject

Returns the value of attribute minor_version.



57
58
59
# File 'lib/origami/extensions/ppklite.rb', line 57

def minor_version
  @minor_version
end

Class Method Details

.parse(stream) ⇒ Object

:nodoc:



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/origami/extensions/ppklite.rb', line 68

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)

    PPKLite::Header.new(maj, min)
end

Instance Method Details

#to_fObject

:nodoc:



92
93
94
# File 'lib/origami/extensions/ppklite.rb', line 92

def to_f #:nodoc:
    to_sym.to_s.to_f
end

#to_sObject

Outputs self into PDF code.



84
85
86
# File 'lib/origami/extensions/ppklite.rb', line 84

def to_s
    "%PPKLITE-#{@major_version}.#{@minor_version}".b + EOL
end

#to_symObject

:nodoc:



88
89
90
# File 'lib/origami/extensions/ppklite.rb', line 88

def to_sym #:nodoc:
    "#{@major_version}.#{@minor_version}".to_sym
end