Class: CVGen::ErbContext

Inherits:
BasicObject
Defined in:
lib/cvgen.rb

Instance Method Summary collapse

Constructor Details

#initialize(features) ⇒ ErbContext

Returns a new instance of ErbContext.



28
29
30
31
# File 'lib/cvgen.rb', line 28

def initialize(features)
  @features = features
  @sections = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



33
34
35
# File 'lib/cvgen.rb', line 33

def method_missing(method, *args)
  @features.include?(method.to_s)
end

Instance Method Details

#create_section(name) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cvgen.rb', line 37

def create_section(name)
  $stderr.puts "Warning: Overwriting section \"#{name}\"" if @sections.has_key?(name)

  buf = ''
  @output_buffer, temp = buf, @output_buffer

  yield

  @sections[name] = buf
ensure
  @output_buffer = temp
end

#section(name) ⇒ Object



50
51
52
53
# File 'lib/cvgen.rb', line 50

def section(name)
  $stderr.puts "Warning: No section \"#{name}\"" unless @sections.has_key?(name)
  @sections[name]
end