lib/receipt/pdf.rb in receipt-0.1.0 vs lib/receipt/pdf.rb in receipt-0.1.1
- old
+ new
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
require 'ostruct'
require 'i18n'
module Receipt
- class MissingRequiredParamError < StandardError; end
class Pdf
extend Forwardable
include Prawn::View
@@ -71,10 +70,18 @@
end
@errors.size == 0
end
+ def filename
+ File.basename(path)
+ end
+
+ def mimetype
+ 'application/pdf'
+ end
+
private
def generate
valid?
@@ -127,19 +134,19 @@
def formated_amount
[
currency,
amount
- ].join(' ')
+ ].compact.join(' ')
end
def date_box(x, y, width)
bounding_box [x, y], width: width do
text(
[
location,
l(date, format: :long)
- ].join(', ')
+ ].compact.join(', ')
)
end
end
def receipt_box