module SellObject::Buscape
Public Class Methods
included(base)
click to toggle source
# File lib/sell_object/buscape.rb, line 3 def self.included(base) base.extend ClassMethods end
timestamp()
click to toggle source
# File lib/sell_object/buscape.rb, line 22 def self.timestamp now = Time.now zone_diff = now.strftime("%z").to_i / 100 time = now.strftime "%Y-%m-%dT%H:%M:%SGMT#{'+' if zone_diff >= 0}#{zone_diff}" "Generated at #{time}" end
wrap_xml(elements, store_name = nil)
click to toggle source
# File lib/sell_object/buscape.rb, line 7 def self.wrap_xml(elements, store_name = nil) store_name ||= SellObject::Config.store_name raise ArgumentError, 'No store name found (nil). You have to either pass it as an argument or set it up in SellObject::Config' if store_name.nil? store_name = store_name.gsub(/ +/, '_') result = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml| xml.comment timestamp xml.send(store_name) { xml.produtos do xml << elements end } end result.to_xml end
Public Instance Methods
to_buscape(store_name = nil)
click to toggle source
Instance methods added on inclusion
# File lib/sell_object/buscape.rb, line 40 def to_buscape(store_name = nil) self.class.to_buscape [self], store_name end