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
80
81
# File 'lib/origami/extensions/ppklite.rb', line 68

def self.parse(stream) #:nodoc:
    scanner = Parser.init_scanner(stream)

    if not 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)

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

Instance Method Details

#to_fObject

:nodoc:



94
95
96
# File 'lib/origami/extensions/ppklite.rb', line 94

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

#to_s(eol: $/) ⇒ Object

Outputs self into PDF code.



86
87
88
# File 'lib/origami/extensions/ppklite.rb', line 86

def to_s(eol: $/)
    "%PPKLITE-#{@major_version}.#{@minor_version}".b + eol
end

#to_symObject

:nodoc:



90
91
92
# File 'lib/origami/extensions/ppklite.rb', line 90

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