Class: Passbook::PKPass
- Inherits:
-
Object
- Object
- Passbook::PKPass
- Defined in:
- lib/passbook/pkpass.rb
Constant Summary collapse
- TYPES =
['boarding-pass', 'coupon', 'event-ticket', 'store-card', 'generic']
Instance Attribute Summary collapse
-
#manifest_files ⇒ Object
Returns the value of attribute manifest_files.
-
#pass ⇒ Object
Returns the value of attribute pass.
-
#signer ⇒ Object
Returns the value of attribute signer.
Instance Method Summary collapse
- #addFile(file) ⇒ Object
- #addFiles(files) ⇒ Object
- #build ⇒ Object
-
#create ⇒ Object
Backward compatibility.
-
#file(options = {}) ⇒ Object
Return a Tempfile containing our ZipStream.
-
#initialize(pass, init_signer = nil) ⇒ PKPass
constructor
A new instance of PKPass.
-
#json=(json) ⇒ Object
for backwards compatibility.
-
#stream ⇒ Object
Return a ZipOutputStream.
Constructor Details
Instance Attribute Details
#manifest_files ⇒ Object
Returns the value of attribute manifest_files.
8 9 10 |
# File 'lib/passbook/pkpass.rb', line 8 def manifest_files @manifest_files end |
#pass ⇒ Object
Returns the value of attribute pass.
8 9 10 |
# File 'lib/passbook/pkpass.rb', line 8 def pass @pass end |
#signer ⇒ Object
Returns the value of attribute signer.
8 9 10 |
# File 'lib/passbook/pkpass.rb', line 8 def signer @signer end |
Instance Method Details
#addFile(file) ⇒ Object
18 19 20 |
# File 'lib/passbook/pkpass.rb', line 18 def addFile(file) @manifest_files << file end |
#addFiles(files) ⇒ Object
22 23 24 |
# File 'lib/passbook/pkpass.rb', line 22 def addFiles(files) @manifest_files += files end |
#build ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/passbook/pkpass.rb', line 31 def build manifest = createManifest # Check pass for necessary files and fields checkPass manifest # Create pass signature signature = @signer.sign manifest [manifest, signature] end |
#create ⇒ Object
Backward compatibility
44 45 46 |
# File 'lib/passbook/pkpass.rb', line 44 def create self.file.path end |
#file(options = {}) ⇒ Object
Return a Tempfile containing our ZipStream
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/passbook/pkpass.rb', line 49 def file( = {}) [:file_name] ||= 'pass.pkpass' temp_file = Tempfile.new([:file_name]) temp_file.binmode temp_file.write self.stream.string temp_file.close temp_file end |
#json=(json) ⇒ Object
for backwards compatibility
27 28 29 |
# File 'lib/passbook/pkpass.rb', line 27 def json=(json) @pass = json end |
#stream ⇒ Object
Return a ZipOutputStream
61 62 63 64 65 |
# File 'lib/passbook/pkpass.rb', line 61 def stream manifest, signature = build outputZip manifest, signature end |