class HTMLParser::Tag
Attributes
attrs[RW]
children[RW]
name[RW]
Public Class Methods
from_str(s)
click to toggle source
# File lib/html-renderer/html_parser.rb, line 25 def self.from_str(s) name, rest = s.split(/\s+/, 2) if rest attrs = rest.scan(HTMLParser::ATTR_RE).flatten.compact.each_slice(2).to_h else attrs = {} end new(name, attrs) end
new(name, attrs={}, children=[])
click to toggle source
# File lib/html-renderer/html_parser.rb, line 36 def initialize(name, attrs={}, children=[]) @name = name @attrs = attrs @children = children end
Public Instance Methods
recursive_inspect(depth=0)
click to toggle source
# File lib/html-renderer/html_parser.rb, line 42 def recursive_inspect(depth=0) curdent = " "*depth indent = " "*(depth+1) "#{curdent}<#{name} #{attrs}>\n#{indent}#{children.map{|c| c.recursive_inspect(depth+1)}}\n#{curdent}</#{name}>" end