Created
December 3, 2015 03:07
-
-
Save GusGA/2468b64249df83fb7e75 to your computer and use it in GitHub Desktop.
MetaFlojera
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'nokogiri' | |
module Suites | |
module XML | |
BASE_URL = 'http://menuboardmanager.com/xml/' | |
class << self | |
def prices_url | |
{ | |
:week_promo => 'dallassuiteshotelDiario.xml', | |
:week_full => 'dallassuiteshotelPreciosDiario.xml', | |
:weekend_promo => 'dallassuiteshotelWeekend.xml', | |
:weekend_full => 'dallassuiteshotelPreciosWeekend.xml' | |
} | |
end | |
def regular_suites | |
[:plus, :plus_jacuzzi, :duplex, :deluxe, :presidential] | |
end | |
def vip_suites | |
[:new_concept, :sexy, :barn, :steam_barn, :hotel, :spa, :boutique, :spa, :container, :le_grande] | |
end | |
def price_item_xpath | |
'//item' | |
end | |
def set_suites | |
prices_url.keys.each do |suite_type| | |
define_singleton_method(suite_type) do | |
doc = Nokogiri::XML(open(BASE_URL + prices_url[suite_type])) | |
prices = doc.xpath('//item').map do |node| | |
node.children.text.strip.split("\n\t\t\t").last.scan(/\d+/).join('.') | |
end | |
prices.each_slice(2).to_a | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment