Class: Wiki::Api::Util
- Inherits:
-
Object
- Object
- Wiki::Api::Util
- Defined in:
- lib/wiki/api/util.rb
Class Method Summary collapse
- .element_filter_lists(element) ⇒ Object
- .element_to_text(element) ⇒ Object
- .parent_root(current_object) ⇒ Object
Class Method Details
.element_filter_lists(element) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/wiki/api/util.rb', line 13 def element_filter_lists element raise "not an element" unless element.is_a? Nokogiri::XML::Element result = {} element.search("li").each_with_index do |li, i| li.children.each do |child| result[i] ||= [] result[i] << self.clean_text(child.text) end end result.map{ |k,v| v.join("") } end |
.element_to_text(element) ⇒ Object
8 9 10 11 |
# File 'lib/wiki/api/util.rb', line 8 def element_to_text element raise "not an element" unless element.is_a? Nokogiri::XML::Element self.clean_text element.text end |
.parent_root(current_object) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/wiki/api/util.rb', line 25 def parent_root current_object current = current_object while true do break if current.parent.nil? current = current.parent end current end |