Class: BetterHtml::Tree::Tag
- Inherits:
-
Object
- Object
- BetterHtml::Tree::Tag
- Defined in:
- lib/better_html/tree/tag.rb
Instance Attribute Summary collapse
-
#attributes_node ⇒ Object
readonly
Returns the value of attribute attributes_node.
-
#end_solidus ⇒ Object
readonly
Returns the value of attribute end_solidus.
-
#name_node ⇒ Object
readonly
Returns the value of attribute name_node.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#start_solidus ⇒ Object
readonly
Returns the value of attribute start_solidus.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
- #closing? ⇒ Boolean
-
#initialize(node) ⇒ Tag
constructor
A new instance of Tag.
- #loc ⇒ Object
- #name ⇒ Object
- #self_closing? ⇒ Boolean
Constructor Details
#initialize(node) ⇒ Tag
Returns a new instance of Tag.
17 18 19 20 |
# File 'lib/better_html/tree/tag.rb', line 17 def initialize(node) @node = node @start_solidus, @name_node, @attributes_node, @end_solidus = *node end |
Instance Attribute Details
#attributes_node ⇒ Object (readonly)
Returns the value of attribute attributes_node.
9 10 11 |
# File 'lib/better_html/tree/tag.rb', line 9 def attributes_node @attributes_node end |
#end_solidus ⇒ Object (readonly)
Returns the value of attribute end_solidus.
9 10 11 |
# File 'lib/better_html/tree/tag.rb', line 9 def end_solidus @end_solidus end |
#name_node ⇒ Object (readonly)
Returns the value of attribute name_node.
9 10 11 |
# File 'lib/better_html/tree/tag.rb', line 9 def name_node @name_node end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
9 10 11 |
# File 'lib/better_html/tree/tag.rb', line 9 def node @node end |
#start_solidus ⇒ Object (readonly)
Returns the value of attribute start_solidus.
9 10 11 |
# File 'lib/better_html/tree/tag.rb', line 9 def start_solidus @start_solidus end |
Class Method Details
.from_node(node) ⇒ Object
12 13 14 |
# File 'lib/better_html/tree/tag.rb', line 12 def from_node(node) new(node) end |
Instance Method Details
#attributes ⇒ Object
38 39 40 |
# File 'lib/better_html/tree/tag.rb', line 38 def attributes @attributes ||= AttributesList.from_nodes(@attributes_node.to_a) end |
#closing? ⇒ Boolean
30 31 32 |
# File 'lib/better_html/tree/tag.rb', line 30 def closing? @start_solidus&.type == :solidus end |
#loc ⇒ Object
22 23 24 |
# File 'lib/better_html/tree/tag.rb', line 22 def loc @node.loc end |
#name ⇒ Object
26 27 28 |
# File 'lib/better_html/tree/tag.rb', line 26 def name @name_node&.loc&.source&.downcase end |
#self_closing? ⇒ Boolean
34 35 36 |
# File 'lib/better_html/tree/tag.rb', line 34 def self_closing? @end_solidus&.type == :solidus end |