Class: XWS

Inherits:
Object
  • Object
show all
Defined in:
lib/xws.rb

Instance Method Summary collapse

Constructor Details

#initialize(ignore_elements: %i(pre code time))) ⇒ XWS

Returns a new instance of XWS.



11
12
13
14
15
# File 'lib/xws.rb', line 11

def initialize(ignore_elements: i(pre code time))

  @ignore_elements = ignore_elements

end

Instance Method Details

#scan(node) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/xws.rb', line 17

def scan(node)

  a = []

  node.each_recursive do |x|

    if not x.name[/#{@ignore_elements.join('|')}/] then
      a += x.texts.map(&:strip).select{|x| not x.empty?}
    end
  end

  Yawc.new(a.join(' ')).to_h
  
end