class Storexplore::Walker
Objects representing categories and items of the store. These are the instances manipulated when browsing a previously defined store
Attributes
Internal usage
Internal usage
Internal usage
Internal usage
Internal usage
Public Class Methods
# File lib/storexplore/walker.rb, line 29 def initialize(getter) self.categories_digger = NullDigger.new self.items_digger = NullDigger.new self.scrap_attributes_block = proc do { } end @getter = getter end
Public Instance Methods
Scraped attributes of this page. Attributes are extracted with the corresponding attributes blocks given in Storexplore::Dsl
# File lib/storexplore/walker.rb, line 50 def attributes @attributes ||= scrap_attributes end
Sub categories Storexplore::Walker
, as matched by the corresponding categories selector in Storexplore::Dsl
# File lib/storexplore/walker.rb, line 56 def categories categories_digger.sub_walkers(page, self) end
Extended multiline string representation with parents.
# File lib/storexplore/walker.rb, line 72 def genealogy genealogy_prefix + to_s end
Sub items Storexplore::Walker
, as matched by the corresponding categories selector in Storexplore::Dsl
# File lib/storexplore/walker.rb, line 62 def items items_digger.sub_walkers(page, self) end
Early title, accessible before the page is loaded.
-
for the store root, this is the store uri
-
for other pages, it's the caption of the link that brought to this
# File lib/storexplore/walker.rb, line 39 def title @getter.text end
String representation with uri and index among siblings.
# File lib/storexplore/walker.rb, line 67 def to_s "#{self.class} ##{index} @#{uri}" end
Full uri of the page being browsed
# File lib/storexplore/walker.rb, line 44 def uri page.uri end
Private Instance Methods
# File lib/storexplore/walker.rb, line 81 def genealogy_prefix if father.nil? "" else father.genealogy + "\n" end end
# File lib/storexplore/walker.rb, line 77 def page @page ||= @getter.get end
# File lib/storexplore/walker.rb, line 89 def scrap_attributes begin instance_eval(&@scrap_attributes_block) rescue WalkerPageError => e raise BrowsingError.new("#{e.message}\n#{genealogy}") end end