Module: HTree::Container
- Includes:
- Node
- Defined in:
- lib/htree/extract_text.rb,
lib/htree/loc.rb,
lib/htree/modules.rb,
lib/htree/container.rb
Overview
:stopdoc:
Defined Under Namespace
Constant Summary
Constants included from HTree
DefaultContext, ElementContent, ElementExclusions, ElementInclusions, EmptyBindingObject, HTMLContext, NamedCharacters, NamedCharactersPattern, OmittedAttrName
Instance Method Summary collapse
-
#children ⇒ Object
children
returns children nodes as an array. - #extract_text ⇒ Object
- #find_loc_step(index) ⇒ Object
Methods included from Node
#display_html, #display_xml, #eliminate_raw_string, #generate_xml_output_code, #make_loc, #raw_string, #subst, #subst_internal, #to_node, #to_rexml
Methods included from HTree
#==, build_node, #check_equality, compile_template, #exact_equal?, #exact_equal_object, expand_template, fix_element, fix_structure_list, frozen_string, #hash, #make_exact_equal_object, #make_usual_equal_object, parse, parse_as, parse_pairs, parse_xml, scan, #usual_equal_object, with_frozen_string_hash
Instance Method Details
#children ⇒ Object
children
returns children nodes as an array.
5 6 7 |
# File 'lib/htree/container.rb', line 5 def children @children.dup end |
#extract_text ⇒ Object
20 21 22 |
# File 'lib/htree/extract_text.rb', line 20 def extract_text Text.concat(*@children.map {|n| n.extract_text }) end |
#find_loc_step(index) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/htree/loc.rb', line 100 def find_loc_step(index) if index < 0 || @children.length <= index return "*[#{index}]" end return @loc_step_children[index].dup if defined? @loc_step_children count = {} count.default = 0 steps = [] @children.each {|c| node_test = c.node_test_string count[node_test] += 1 steps << [node_test, count[node_test]] } @loc_step_children = [] steps.each {|node_test, i| if count[node_test] == 1 @loc_step_children << node_test else @loc_step_children << "#{node_test}[#{i}]" end } return @loc_step_children[index].dup end |