Class: Zanders::Catalog
Constant Summary collapse
- CATALOG_FILENAME =
'zandersinv.xml'.freeze
- ITEM_NODE_NAME =
'ZandersDataOut'.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(options = {}) ⇒ Catalog
constructor
A new instance of Catalog.
Methods inherited from Base
Constructor Details
#initialize(options = {}) ⇒ Catalog
Returns a new instance of Catalog.
7 8 9 10 |
# File 'lib/zanders/catalog.rb', line 7 def initialize( = {}) requires!(, :username, :password) @options = end |
Class Method Details
.all(options = {}) ⇒ Object
12 13 14 15 |
# File 'lib/zanders/catalog.rb', line 12 def self.all( = {}) requires!(, :username, :password) new().all end |
Instance Method Details
#all ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/zanders/catalog.rb', line 17 def all items = [] tempfile = get_file(CATALOG_FILENAME) Nokogiri::XML::Reader.from_io(tempfile, nil, Zanders.config.file_encoding).each do |reader| next unless reader.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT next unless reader.name == ITEM_NODE_NAME node = Nokogiri::XML.parse(reader.outer_xml) _map_hash = map_hash(node.css(ITEM_NODE_NAME)) items << _map_hash unless _map_hash.nil? end tempfile.close tempfile.unlink items end |