Class: Nm::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/nm/source.rb

Direct Known Subclasses

DefaultSource

Constant Summary collapse

EXT =
".nm"

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#rootObject (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