Class: Hpricot::STag
- Includes:
- Tag
- Defined in:
- lib/hpricot/tag.rb,
lib/hpricot/inspect.rb,
lib/hpricot/modules.rb
Constant Summary
Constants included from Hpricot
AttrCore, AttrEvents, AttrFocus, AttrHAlign, AttrI18n, AttrVAlign, Attrs, ElementContent, ElementExclusions, ElementInclusions, FORM_TAGS, NamedCharacters, NamedCharactersPattern, OmittedAttrName, PREDEFINED, PREDEFINED_U, SELF_CLOSING_TAGS
Instance Attribute Summary
Attributes inherited from BaseEle
Class Method Summary collapse
Instance Method Summary collapse
- #attributes_as_html ⇒ Object
-
#initialize(name, attributes = nil) ⇒ STag
constructor
A new instance of STag.
- #output(out, opts = {}) ⇒ Object
- #pretty_print(q) ⇒ Object
Methods included from Hpricot
XML, build, build_node, make, scan, uxs, xchr, xs
Methods inherited from BaseEle
alterable, #altered!, #html_quote, #if_output, #pathname
Constructor Details
#initialize(name, attributes = nil) ⇒ STag
Returns a new instance of STag.
98 99 100 101 |
# File 'lib/hpricot/tag.rb', line 98 def initialize(name, attributes=nil) @name = name.to_s @raw_attributes = attributes || {} end |
Class Method Details
.parse(qname, attrs, raw_string, is_stag) ⇒ Object
216 217 218 219 220 |
# File 'lib/hpricot/parse.rb', line 216 def STag.parse(qname, attrs, raw_string, is_stag) result = STag.new(qname, attrs) result.raw_string = raw_string result end |
Instance Method Details
#attributes_as_html ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/hpricot/tag.rb', line 103 def attributes_as_html if @raw_attributes @raw_attributes.map do |aname, aval| " #{aname}" + (aval ? "=#{html_quote aval}" : "") end.join end end |
#output(out, opts = {}) ⇒ Object
111 112 113 114 115 116 117 118 |
# File 'lib/hpricot/tag.rb', line 111 def output(out, opts = {}) out << if_output(opts) do "<#{@name}#{attributes_as_html}" + (opts[:style] == :empty ? " /" : "") + ">" end end |
#pretty_print(q) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/hpricot/inspect.rb', line 59 def pretty_print(q) q.group(1, '<', '>') { q.text @name if @raw_attributes @raw_attributes.each {|n, t| q.breakable if t q.text "#{n}=\"#{Hpricot.uxs(t)}\"" else q.text n end } end } end |