Class: VirtualDOM::VirtualNode
- Inherits:
-
Object
- Object
- VirtualDOM::VirtualNode
- Defined in:
- lib/virtual_dom/virtual_node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(name, params = {}, children = []) ⇒ VirtualNode
constructor
A new instance of VirtualNode.
- #to_s ⇒ Object
- #to_s_children ⇒ Object
- #to_s_params ⇒ Object
Constructor Details
#initialize(name, params = {}, children = []) ⇒ VirtualNode
Returns a new instance of VirtualNode.
7 8 9 10 11 |
# File 'lib/virtual_dom/virtual_node.rb', line 7 def initialize(name, params = {}, children = []) @name = name @params = params @children = children end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
5 6 7 |
# File 'lib/virtual_dom/virtual_node.rb', line 5 def children @children end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/virtual_dom/virtual_node.rb', line 5 def name @name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/virtual_dom/virtual_node.rb', line 5 def params @params end |
Instance Method Details
#to_s ⇒ Object
13 14 15 |
# File 'lib/virtual_dom/virtual_node.rb', line 13 def to_s "<#{@name}#{to_s_params}>#{to_s_children}</#{@name}>" end |
#to_s_children ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/virtual_dom/virtual_node.rb', line 23 def to_s_children return @children if @children.is_a?(String) return unless @children.any? @children .map(&:to_s) .join end |
#to_s_params ⇒ Object
17 18 19 20 21 |
# File 'lib/virtual_dom/virtual_node.rb', line 17 def to_s_params return unless @params.any? " #{@params.map { |k, v| "#{k}=\"#{v}\"" }.join(" ")}" end |