Sha256: ed1604a1c196f56e8c79e40b7fdcf1ce496c66c1665286fce3718cdc689b5d42
Contents?: true
Size: 935 Bytes
Versions: 1
Compression:
Stored size: 935 Bytes
Contents
module Erector class HtmlParts < Array def to_s map do |part| case part['type'] when 'open' part['attributes'] ? "<#{part['tagName']}#{format_attributes(part['attributes'])}>" : "<#{part['tagName']}>" when 'close' "</#{part['tagName']}>" when 'standalone' part['attributes'] ? "<#{part['tagName']}#{format_attributes(part['attributes'])} />" : "<#{part['tagName']} />" when 'text' part['value'].to_s when 'instruct' "<?xml#{format_attributes(part['attributes'])}?>" end end.join end protected def format_attributes(attributes) return "" if !attributes || attributes.empty? results = [''] attributes.each do |key, value| results << "#{key}=#{value.to_s.inspect}" if value end results.join ' ' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
erector-0.1.0 | lib/erector/html_parts.rb |