Class: Excesselt::ElementWrapper
- Inherits:
-
Object
- Object
- Excesselt::ElementWrapper
- Defined in:
- lib/excesselt/element_wrapper.rb
Instance Attribute Summary collapse
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#stylesheet ⇒ Object
readonly
Returns the value of attribute stylesheet.
Instance Method Summary collapse
- #add(*content) ⇒ Object
- #child_content(selector = nil) ⇒ Object
- #error(string) ⇒ Object
-
#initialize(stylesheet, element, builder) ⇒ ElementWrapper
constructor
A new instance of ElementWrapper.
- #method_missing(sym, *args) ⇒ Object
Constructor Details
#initialize(stylesheet, element, builder) ⇒ ElementWrapper
Returns a new instance of ElementWrapper.
6 7 8 9 10 |
# File 'lib/excesselt/element_wrapper.rb', line 6 def initialize(stylesheet, element, builder) @stylesheet = stylesheet @element = element @builder = builder end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/excesselt/element_wrapper.rb', line 19 def method_missing(sym, *args) begin @element.send(sym, *args) rescue Exception => e raise e.exception("Error delegating method '#{sym}' to #{@element.class.name}: #{e.}\n\n#{e.backtrace.join("\n")}") end end |
Instance Attribute Details
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
4 5 6 |
# File 'lib/excesselt/element_wrapper.rb', line 4 def builder @builder end |
#element ⇒ Object (readonly)
Returns the value of attribute element.
4 5 6 |
# File 'lib/excesselt/element_wrapper.rb', line 4 def element @element end |
#stylesheet ⇒ Object (readonly)
Returns the value of attribute stylesheet.
4 5 6 |
# File 'lib/excesselt/element_wrapper.rb', line 4 def stylesheet @stylesheet end |
Instance Method Details
#add(*content) ⇒ Object
27 28 29 |
# File 'lib/excesselt/element_wrapper.rb', line 27 def add(*content) @builder << content.join('') end |
#child_content(selector = nil) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/excesselt/element_wrapper.rb', line 12 def child_content(selector=nil) elements = selector ? @element.css(selector) : @element.children elements.each do |child| stylesheet.generate_element(child) end end |
#error(string) ⇒ Object
31 32 33 |
# File 'lib/excesselt/element_wrapper.rb', line 31 def error(string) stylesheet.errors << string end |