Class: Storexplore::Walker
- Inherits:
-
Object
- Object
- Storexplore::Walker
- Defined in:
- lib/storexplore/walker.rb
Overview
Objects representing categories and items of the store. These are the instances manipulated when browsing a previously defined store
Instance Attribute Summary collapse
-
#categories_digger ⇒ Object
Internal usage.
-
#father ⇒ Object
Internal usage.
-
#index ⇒ Object
Internal usage.
-
#items_digger ⇒ Object
Internal usage.
-
#scrap_attributes_block ⇒ Object
Internal usage.
Instance Method Summary collapse
-
#attributes ⇒ Object
Scraped attributes of this page.
-
#categories ⇒ Object
Sub categories Storexplore::Walker, as matched by the corresponding categories selector in Storexplore::Dsl.
-
#genealogy ⇒ Object
Extended multiline string representation with parents.
-
#initialize(getter) ⇒ Walker
constructor
A new instance of Walker.
-
#items ⇒ Object
Sub items Storexplore::Walker, as matched by the corresponding categories selector in Storexplore::Dsl.
-
#title ⇒ Object
Early title, accessible before the page is loaded.
-
#to_s ⇒ Object
String representation with uri and index among siblings.
-
#uri ⇒ Object
Full uri of the page being browsed.
Constructor Details
#initialize(getter) ⇒ Walker
Returns a new instance of Walker.
30 31 32 33 34 35 |
# File 'lib/storexplore/walker.rb', line 30 def initialize(getter) self.categories_digger = NullDigger.new self.items_digger = NullDigger.new self.scrap_attributes_block = proc do { } end @getter = getter end |
Instance Attribute Details
#categories_digger ⇒ Object
Internal usage
28 29 30 |
# File 'lib/storexplore/walker.rb', line 28 def categories_digger @categories_digger end |
#father ⇒ Object
Internal usage
28 29 30 |
# File 'lib/storexplore/walker.rb', line 28 def father @father end |
#index ⇒ Object
Internal usage
28 29 30 |
# File 'lib/storexplore/walker.rb', line 28 def index @index end |
#items_digger ⇒ Object
Internal usage
28 29 30 |
# File 'lib/storexplore/walker.rb', line 28 def items_digger @items_digger end |
#scrap_attributes_block ⇒ Object
Internal usage
28 29 30 |
# File 'lib/storexplore/walker.rb', line 28 def scrap_attributes_block @scrap_attributes_block end |
Instance Method Details
#attributes ⇒ Object
Scraped attributes of this page. Attributes are extracted with the corresponding attributes blocks given in Storexplore::Dsl
51 52 53 |
# File 'lib/storexplore/walker.rb', line 51 def attributes @attributes ||= scrap_attributes end |
#categories ⇒ Object
Sub categories Storexplore::Walker, as matched by the corresponding categories selector in Storexplore::Dsl
57 58 59 |
# File 'lib/storexplore/walker.rb', line 57 def categories categories_digger.sub_walkers(page, self) end |
#genealogy ⇒ Object
Extended multiline string representation with parents.
73 74 75 |
# File 'lib/storexplore/walker.rb', line 73 def genealogy genealogy_prefix + to_s end |
#items ⇒ Object
Sub items Storexplore::Walker, as matched by the corresponding categories selector in Storexplore::Dsl
63 64 65 |
# File 'lib/storexplore/walker.rb', line 63 def items items_digger.sub_walkers(page, self) end |
#title ⇒ Object
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
40 41 42 |
# File 'lib/storexplore/walker.rb', line 40 def title @getter.text end |
#to_s ⇒ Object
String representation with uri and index among siblings.
68 69 70 |
# File 'lib/storexplore/walker.rb', line 68 def to_s "#{self.class} ##{index} @#{uri}" end |
#uri ⇒ Object
Full uri of the page being browsed
45 46 47 |
# File 'lib/storexplore/walker.rb', line 45 def uri page.uri end |