class Shuwar::Stdlib::Nokogiri::HtmlTag
Public Class Methods
new(name, attrs, *children)
click to toggle source
# File lib/shuwar/stdlib/nokogiri.rb, line 14 def initialize(name, attrs, *children) @name = name.to_s @attrs = attrs.to_h if children.all? {|a| a.is_a? String} # Multi strings should get a space between them @children = [children.join(" ")] else @children = children end end
Public Instance Methods
add_to(a)
click to toggle source
# File lib/shuwar/stdlib/nokogiri.rb, line 25 def add_to(a) ele = a.document.create_element @name, @attrs @children.each do |c| case c when String then ele << c else c.add_to ele end end a << ele end