Class: HtmlWriter
- Inherits:
-
Object
show all
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- lib/wheels/html_writer.rb
Instance Method Summary
collapse
Constructor Details
#initialize(representation = {}) ⇒ HtmlWriter
Returns a new instance of HtmlWriter.
6
7
8
|
# File 'lib/wheels/html_writer.rb', line 6
def initialize(representation={})
@representation = representation
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/wheels/html_writer.rb', line 19
def method_missing(sym, *args, &block)
if args[0].is_a? Array
end
@representation[sym] = {:args=>args[0]}
if block_given?
block.call(self)
end
return HtmlWriter.new(@representation[sym])
end
|
Instance Method Details
#[](html_class) ⇒ Object
35
36
37
38
|
# File 'lib/wheels/html_writer.rb', line 35
def [](html_class)
@representation[:args][:class] = html_class.to_s
return self
end
|
#html ⇒ Object
44
45
46
47
|
# File 'lib/wheels/html_writer.rb', line 44
def html
concat
end
|
#id(_id) ⇒ Object
40
41
42
|
# File 'lib/wheels/html_writer.rb', line 40
def id(_id)
@representation[:args][:class] = _id.to_s
end
|
#val(value) ⇒ Object
30
31
32
33
|
# File 'lib/wheels/html_writer.rb', line 30
def val(value)
@representation[:value] = value
return self
end
|