Module: Camp::Hadomisaki

Defined in:
lib/camp/hadomisaki.rb

Class Method Summary collapse

Class Method Details

.nameObject



4
5
6
# File 'lib/camp/hadomisaki.rb', line 4

def name
  "Hadomisaki"
end

.possible_days(doc) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/camp/hadomisaki.rb', line 8

def possible_days(doc)
  doc.xpath('//a').map {|element| element["href"]}.compact.map do |link|
    if link =~ /autocamp.*startdate/
      DateTime.parse(link.gsub(/.*startdate=([0-9]{4}-[0-9]{2}-[0-9]{2}).*/, '\1'))
    end
  end.compact
end

.sitesObject



20
21
22
23
24
25
26
27
# File 'lib/camp/hadomisaki.rb', line 20

def sites
  ["", %q(?next=1&period=1#container)].map do |param|
    charset = 'utf-8'
    html = URI.open(url + param) { |f| f.read }
    doc = Nokogiri::HTML.parse(html, nil, charset)
    ::Camp::Site.new(name, possible_days(doc))
  end
end

.urlObject



16
17
18
# File 'lib/camp/hadomisaki.rb', line 16

def url
  'https://www.hadomisaki-camp.jp/reservation/calendar/'
end