Class: DNote::Format::ErbScope

Inherits:
Object
  • Object
show all
Defined in:
lib/dnote/format.rb

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ ErbScope

Returns a new instance of ErbScope.



152
153
154
# File 'lib/dnote/format.rb', line 152

def initialize(data={})
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(s, *a) ⇒ Object



165
166
167
# File 'lib/dnote/format.rb', line 165

def method_missing(s, *a)
  @data[s.to_sym]
end

Instance Method Details

#h(string) ⇒ Object



161
162
163
# File 'lib/dnote/format.rb', line 161

def h(string)
  REXML::Text.normalize(string)
end

#render(file) ⇒ Object



156
157
158
159
# File 'lib/dnote/format.rb', line 156

def render(file)
  erb = ERB.new(File.read(file), nil, '<>')
  erb.result(binding)
end