Class: Badger::Template
- Inherits:
-
Object
- Object
- Badger::Template
- Defined in:
- lib/badger/template.rb
Defined Under Namespace
Classes: FormatError
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
- #absolute_path ⇒ Object
- #badges_per_page ⇒ Object
-
#initialize(filename) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(filename) ⇒ Template
Returns a new instance of Template.
8 9 10 |
# File 'lib/badger/template.rb', line 8 def initialize(filename) @filename = filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
7 8 9 |
# File 'lib/badger/template.rb', line 7 def filename @filename end |
Instance Method Details
#absolute_path ⇒ Object
12 13 14 |
# File 'lib/badger/template.rb', line 12 def absolute_path File.(@filename) end |
#badges_per_page ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/badger/template.rb', line 16 def badges_per_page @badges_per_page ||= begin data_fields = `pdftk '#{@filename}' dump_data_fields` per_page = data_fields.scan(/first_name(\d+)/).flatten.map(&:to_i).max if per_page.zero? raise FormatError, "No badges found in template #{@filename}; see badger -h" else per_page end end end |