Class: Magneto::Template
- Inherits:
-
Object
- Object
- Magneto::Template
- Includes:
- Readable
- Defined in:
- lib/magneto/template.rb
Instance Attribute Summary collapse
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
- #import_metadata ⇒ Object
-
#initialize(site, path, name) ⇒ Template
constructor
A new instance of Template.
- #use_filter(filter_name) ⇒ Object
Methods included from Readable
#content, #content=, #content?, #metadata, #metadata=, #metadata?, #read
Constructor Details
#initialize(site, path, name) ⇒ Template
Returns a new instance of Template.
8 9 10 11 12 13 14 15 16 |
# File 'lib/magneto/template.rb', line 8 def initialize(site, path, name) super() @site = site @path = path @name = name @filter = nil @metadata = nil @content = nil end |
Instance Attribute Details
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
6 7 8 |
# File 'lib/magneto/template.rb', line 6 def filter @filter end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/magneto/template.rb', line 6 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/magneto/template.rb', line 6 def path @path end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
6 7 8 |
# File 'lib/magneto/template.rb', line 6 def site @site end |
Instance Method Details
#import_metadata ⇒ Object
27 28 29 |
# File 'lib/magneto/template.rb', line 27 def @filter = use_filter(@metadata[:filter]) unless @metadata.nil? || @metadata[:filter].nil? end |
#use_filter(filter_name) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/magneto/template.rb', line 18 def use_filter(filter_name) @filter = @site.filters[filter_name.to_sym] if @filter.nil? $stderr.puts "#{File.basename($PROGRAM_NAME)}: #{ex.to_s}" raise "Couldn't find filter: '#{filter_name.to_s}'" end end |