Class: Gumbo::Element
- Inherits:
-
Node
- Object
- Node
- Gumbo::Element
show all
- Defined in:
- ext/ruby_gumbo_ext.c,
lib/gumbo/element.rb
Instance Attribute Summary collapse
Attributes inherited from Node
#parent, #parse_flags, #type
Instance Method Summary
collapse
Methods inherited from Node
#dump_tree
Instance Attribute Details
#attributes ⇒ Object
#children ⇒ Object
#end_pos ⇒ Object
#original_end_tag ⇒ Object
#original_end_tag_name ⇒ Object
#original_tag ⇒ Object
#original_tag_name ⇒ Object
#start_pos ⇒ Object
#tag ⇒ Object
#tag_namespace ⇒ Object
Instance Method Details
#attribute ⇒ Object
26
|
# File 'ext/ruby_gumbo_ext.c', line 26
VALUE r_element_attribute(VALUE self, VALUE name);
|
#content_range ⇒ Object
The byte offset range where the content inside this node exists, or nil if the node was inserted algorithmically, or has no content.
47
48
49
50
51
|
# File 'lib/gumbo/element.rb', line 47
def content_range
return nil unless original_tag && original_end_tag
(start_pos.offset + original_tag.bytesize)...end_pos.offset
end
|
#has_attribute? ⇒ Boolean
27
|
# File 'ext/ruby_gumbo_ext.c', line 27
VALUE r_element_has_attribute(VALUE self, VALUE name);
|
#offset_range ⇒ Object
The byte offset range where this element was extracted from, or nil if it was inserted algorithmically.
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/gumbo/element.rb', line 34
def offset_range
return nil unless original_tag
if original_end_tag
end_offset = end_pos.offset + original_end_tag.bytesize
else
end_offset = start_pos.offset + original_tag.bytesize
end
start_pos.offset...end_offset
end
|
#to_s ⇒ Object
Also known as:
inspect
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/gumbo/element.rb', line 18
def to_s
if original_tag
open_tag = original_tag
end_tag = original_end_tag || ''
else
tag_name = original_tag_name || tag
open_tag = "<#{tag_name}>"
end_tag = "</#{tag_name}>"
end
open_tag + (children || []).map(&:to_s).join + end_tag
end
|