Class: Zanders::Catalog
Constant Summary collapse
- CATALOG_FILENAME =
'zandersinv.xml'
- ITEM_NODE_NAME =
'ZandersDataOut'
Class Method Summary collapse
Instance Method Summary collapse
- #all(&block) ⇒ 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 = {}, &block) ⇒ Object
12 13 14 15 |
# File 'lib/zanders/catalog.rb', line 12 def self.all( = {}, &block) requires!(, :username, :password) new().all &block end |
Instance Method Details
#all(&block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/zanders/catalog.rb', line 17 def all(&block) tempfile = get_file(CATALOG_FILENAME) Nokogiri::XML::Reader.from_io(tempfile).each do |node| next unless node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT next unless node.name == ITEM_NODE_NAME yield map_hash(Nokogiri::XML::DocumentFragment.parse(node.inner_xml)) end tempfile.close tempfile.unlink end |