Module: Baiduserp::Parser::Result_Num

Defined in:
lib/baiduserp/parser/result_num.rb

Class Method Summary collapse

Class Method Details

.parse(file) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/baiduserp/parser/result_num.rb', line 4

def self.parse(file)
  html = file[:html]
  str = html.scan(/找到相关结果(.*)个/).join
  str = str.gsub('约','')
  if str.include?('万')
    parts = str.split('万')
    result = parts[0].to_i * 10000 + parts[1].to_i
  else
    result = str.gsub(',', '').to_i
  end

  result
end