Module: Sltung

Defined in:
lib/module/sltung.rb

Class Method Summary collapse

Class Method Details

.crawlObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/module/sltung.rb', line 9

def Sltung.crawl
    url = "http://www.sltung.com.tw/tw/BED/bed.html"
    begin
        page = Nokogiri::HTML(open(url))
        text = page.css("body div.wrapper div span").text
        hash = self.get_situation(text)
    rescue Exception => e
        p e.message
        return nil
    end
    return hash
end

.get_situation(text) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/module/sltung.rb', line 22

def self.get_situation(text)
    hash = {}
    hash[:hospital] = "sltung"
    text.split("").each_with_index do |each_text, index|
        next if index == 0
        if index == 1
            hash[:to_119] = each_text.initial
        elsif index == 2
            hash[:wait_see] = each_text.initial
        elsif index == 3
            hash[:wait_push_bed] = each_text.initial
        elsif index == 4
            hash[:wait_bed] = each_text.initial
        elsif index == 5
            hash[:wait_cure_bed] = each_text.initial
        end
    end

    return hash

end