Sha256: d9761cfdf92888c783413ece5303834d8d2f68e3c056e41a96b36b3fbb577970

Contents?: true

Size: 507 Bytes

Versions: 6

Compression:

Stored size: 507 Bytes

Contents

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

    def vnode
      `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
      if @params.any?
        " " + @params.map do |k,v|
          "#{k}=\"#{v}\""
        end.join(' ')
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opal-virtual-dom-0.1.0 opal/virtual_dom/virtual_node.rb
opal-virtual-dom-0.0.5 opal/virtual_dom/virtual_node.rb
opal-virtual-dom-0.0.4 opal/virtual_dom/virtual_node.rb
opal-virtual-dom-0.0.3 opal/virtual_dom/virtual_node.rb
opal-virtual-dom-0.0.2 opal/virtual_dom/virtual_node.rb
opal-virtual-dom-0.0.1 opal/virtual_dom/virtual_node.rb