Class: Nm::Source
- Inherits:
-
Object
- Object
- Nm::Source
- Defined in:
- lib/nm/source.rb
Direct Known Subclasses
Constant Summary collapse
- EXT =
".nm"
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #data(file_path) ⇒ Object
-
#initialize(root) ⇒ Source
constructor
A new instance of Source.
- #render(file_name, locals = nil) ⇒ Object (also: #partial)
Constructor Details
#initialize(root) ⇒ Source
Returns a new instance of Source.
12 13 14 |
# File 'lib/nm/source.rb', line 12 def initialize(root) @root = Pathname.new(root.to_s) end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
10 11 12 |
# File 'lib/nm/source.rb', line 10 def root @root end |
Instance Method Details
#data(file_path) ⇒ Object
16 17 18 |
# File 'lib/nm/source.rb', line 16 def data(file_path) File.send(File.respond_to?(:binread) ? :binread : :read, file_path) end |
#render(file_name, locals = nil) ⇒ Object Also known as: partial
20 21 22 |
# File 'lib/nm/source.rb', line 20 def render(file_name, locals = nil) Template.new(self, source_file_path(file_name), locals || {}).__data__ end |