Class: Skr::Print::Template::Definition
- Inherits:
-
Object
- Object
- Skr::Print::Template::Definition
- Defined in:
- lib/skr/print/template.rb
Instance Method Summary collapse
- #choices ⇒ Object
-
#initialize(path) ⇒ Definition
constructor
A new instance of Definition.
- #model ⇒ Object
- #name ⇒ Object
- #path_for_record(record) ⇒ Object
Constructor Details
#initialize(path) ⇒ Definition
Returns a new instance of Definition.
6 7 8 |
# File 'lib/skr/print/template.rb', line 6 def initialize(path) @path = path end |
Instance Method Details
#choices ⇒ Object
12 13 14 15 16 |
# File 'lib/skr/print/template.rb', line 12 def choices Pathname.glob(@path.join('*.tex.erb')).map{|pn| pn.basename('.tex.erb').to_s } end |
#model ⇒ Object
17 18 19 |
# File 'lib/skr/print/template.rb', line 17 def model "skr/#{name}".underscore.classify.constantize end |
#name ⇒ Object
9 10 11 |
# File 'lib/skr/print/template.rb', line 9 def name @path.basename.to_s end |
#path_for_record(record) ⇒ Object
20 21 22 23 24 |
# File 'lib/skr/print/template.rb', line 20 def path_for_record(record) form = record.respond_to?(:form) ? record.form : 'default' path = @path.join( form + '.tex.erb' ) path.exist? ? path : @path.join( 'default.tex.erb' ) end |