Sha256: 44a8e985c0c00999ef860293205fbea910623934df4ab16d5c7473882e6c70f8

Contents?: true

Size: 502 Bytes

Versions: 5

Compression:

Stored size: 502 Bytes

Contents

module VirtualDOM
  class VirtualNode
    def initialize(name, params = {}, childrens = [])
      @name = name
      @params = params
      @childrens = childrens
    end

    def to_n
      `virtualDom.h(#{@name}, #{@params.to_n}, #{@childrens})`
    end

    def to_s
      "<#{@name}#{to_s_params}>#{@childrens.map(&:to_s).join}</#{@name}>"
    end

    def to_s_params
      return unless @params.any?
      ' ' + @params.map do |k, v|
        "#{k}=\"#{v}\""
      end.join(' ')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opal-virtual-dom-0.3.0 opal/virtual_dom/virtual_node.rb
opal-virtual-dom-0.2.3 opal/virtual_dom/virtual_node.rb
opal-virtual-dom-0.2.2 opal/virtual_dom/virtual_node.rb
opal-virtual-dom-0.2.1 opal/virtual_dom/virtual_node.rb
opal-virtual-dom-0.2.0 opal/virtual_dom/virtual_node.rb