Skip to content

Instantly share code, notes, and snippets.

@GusGA
Created December 3, 2015 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GusGA/2468b64249df83fb7e75 to your computer and use it in GitHub Desktop.
Save GusGA/2468b64249df83fb7e75 to your computer and use it in GitHub Desktop.
MetaFlojera
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