Class: Browser::DOM::Builder
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#element ⇒ Object
readonly
Returns the value of attribute element.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(document, &block) ⇒ Builder
constructor
A new instance of Builder.
- #to_a ⇒ Object
Constructor Details
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
39 40 41 |
# File 'opal/browser/dom/builder.rb', line 39 def document @document end |
#element ⇒ Object (readonly)
Returns the value of attribute element.
39 40 41 |
# File 'opal/browser/dom/builder.rb', line 39 def element @element end |
Class Method Details
.build(builder, item) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'opal/browser/dom/builder.rb', line 29 def self.build(builder, item) to_h.each {|klass, block| if klass === item return block.call(builder, item) end } raise ArgumentError, "cannot build unknown item #{item}" end |
.for(klass, &block) ⇒ Object
21 22 23 24 25 26 27 |
# File 'opal/browser/dom/builder.rb', line 21 def self.for(klass, &block) if block to_h[klass] = block else to_h[klass] end end |
.to_h ⇒ Object
17 18 19 |
# File 'opal/browser/dom/builder.rb', line 17 def self.to_h @builders ||= {} end |
Instance Method Details
#to_a ⇒ Object
47 48 49 |
# File 'opal/browser/dom/builder.rb', line 47 def to_a @roots end |