Class: Avmtrf1::Forponto::Parsers::Espelho::Utils
- Inherits:
-
Object
- Object
- Avmtrf1::Forponto::Parsers::Espelho::Utils
- Defined in:
- lib/avmtrf1/forponto/parsers/espelho/utils.rb
Class Method Summary collapse
Class Method Details
.sanitize_string(obj) ⇒ Object
24 25 26 |
# File 'lib/avmtrf1/forponto/parsers/espelho/utils.rb', line 24 def sanitize_string(obj) obj.to_s.tr("\u00A0", ' ').strip end |
.string_recursive(node) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/avmtrf1/forponto/parsers/espelho/utils.rb', line 12 def string_recursive(node) return nil unless node.present? return sanitize_string(node.text) if node.is_a?(::Nokogiri::XML::Text) s = '' node.children.each do |child| child_s = string_recursive(child) s += ' ' + child_s if child_s.present? end sanitize_string(s) end |