lib/jekyll-autoscout24/backup_reader.rb in jekyll-autoscout24-0.1.5 vs lib/jekyll-autoscout24/backup_reader.rb in jekyll-autoscout24-0.1.6
- old
+ new
@@ -40,11 +40,47 @@
found = @node.locate(name).first
# no match or empty node, therefore nil
return nil if found.nil? || found.nodes.empty?
# could be an array
return Prices.new(found) if name == 'prices'
+ return Equipments.new(found) if name == 'equipments'
+ return Images.new(found) if name == 'images'
# either text or recurse
found.text === nil ? Entry.new(found) : found.text
+ end
+ end
+
+ class Images < Liquid::Drop
+ include Enumerable
+
+ attr_reader :node
+
+ # ctor
+ def initialize(node)
+ @node = node
+ end
+
+ def each
+ @node.locate("image").each do |n|
+ yield Entry.new(n)
+ end
+ end
+ end
+
+ class Equipments < Liquid::Drop
+ include Enumerable
+
+ attr_reader :node
+
+ # ctor
+ def initialize(node)
+ @node = node
+ end
+
+ def each
+ @node.locate("equipment").each do |n|
+ yield Entry.new(n)
+ end
end
end
class Prices < Liquid::Drop
include Enumerable
\ No newline at end of file