Class: Origami::Adobe::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 =
/\A%PPKLITE-(\d)\.(\d)/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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.



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

def initialize(majorversion = 2, minorversion = 1)
  @majorversion, @minorversion = majorversion, minorversion
end

Instance Attribute Details

#majorversionObject

Returns the value of attribute majorversion.



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

def majorversion
  @majorversion
end

#minorversionObject

Returns the value of attribute minorversion.



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

def minorversion
  @minorversion
end

Class Method Details

.parse(stream) ⇒ Object

:nodoc:



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

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
  
  PPKLite::Header.new(maj,min)
end

Instance Method Details

#to_fObject

:nodoc:



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

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

#to_sObject

Outputs self into PDF code.



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

def to_s
  "%PPKLITE-#{@majorversion}.#{@minorversion}" + EOL
end

#to_symObject

:nodoc:



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

def to_sym #:nodoc:
  "#{@majorversion}.#{@minorversion}".to_sym
end