Class: Interview::Builder
- Inherits:
-
Object
- Object
- Interview::Builder
show all
- Defined in:
- lib/interview/builder.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Builder
Returns a new instance of Builder.
6
7
8
|
# File 'lib/interview/builder.rb', line 6
def initialize(options={})
@html = ::Builder::XmlMarkup.new
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
52
53
54
|
# File 'lib/interview/builder.rb', line 52
def method_missing(sym, *args, &block)
add_abstract!(sym, *args, &block)
end
|
Instance Attribute Details
#curr_parent ⇒ Object
Returns the value of attribute curr_parent.
4
5
6
|
# File 'lib/interview/builder.rb', line 4
def curr_parent
@curr_parent
end
|
#html ⇒ Object
Returns the value of attribute html.
4
5
6
|
# File 'lib/interview/builder.rb', line 4
def html
@html
end
|
Instance Method Details
#<<(text) ⇒ Object
44
45
46
|
# File 'lib/interview/builder.rb', line 44
def <<(text)
@html << text
end
|
#add!(control, &block) ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/interview/builder.rb', line 14
def add!(control, &block)
if @curr_parent.is_a? MetaControl and not @curr_parent.skip
@curr_parent.build_child self, control, &block
else
control.parent = @curr_parent
@curr_parent = control
control.build self, &block
@curr_parent = control.parent
end
end
|
#add_abstract!(sym, *args, &block) ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/interview/builder.rb', line 25
def add_abstract!(sym, *args, &block)
if Object.const_defined?(sym.to_s.camelcase) and
Object.const_get(sym.to_s.camelcase) <= Interview::Control
control = Object.const_get(sym.to_s.camelcase).new(*args)
else
control = Object.const_get("Interview::#{sym.to_s.camelcase}").new(*args)
end
add! control, &block
end
|
#lookup!(attr_name) ⇒ Object
48
49
50
|
# File 'lib/interview/builder.rb', line 48
def lookup!(attr_name)
@curr_parent.find_attribute!(attr_name)
end
|
#render! ⇒ Object
10
11
12
|
# File 'lib/interview/builder.rb', line 10
def render!
@html.target!
end
|
#tag!(sym, *args, &block) ⇒ Object
36
37
38
|
# File 'lib/interview/builder.rb', line 36
def tag!(sym, *args, &block)
@html.tag!(sym, *args, &block)
end
|
#text!(text) ⇒ Object
40
41
42
|
# File 'lib/interview/builder.rb', line 40
def text!(text)
@html.text!(text)
end
|