class Storexplore::Walker

Objects representing categories and items of the store. These are the instances manipulated when browsing a previously defined store

Attributes

categories_digger[RW]

Internal usage

father[RW]

Internal usage

index[RW]

Internal usage

items_digger[RW]

Internal usage

scrap_attributes_block[RW]

Internal usage

Public Class Methods

new(getter) click to toggle source
# 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

attributes() click to toggle source

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
categories() click to toggle source

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
genealogy() click to toggle source

Extended multiline string representation with parents.

# File lib/storexplore/walker.rb, line 72
def genealogy
  genealogy_prefix + to_s
end
items() click to toggle source

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
title() click to toggle source

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
to_s() click to toggle source

String representation with uri and index among siblings.

# File lib/storexplore/walker.rb, line 67
def to_s
  "#{self.class} ##{index} @#{uri}"
end
uri() click to toggle source

Full uri of the page being browsed

# File lib/storexplore/walker.rb, line 44
def uri
  page.uri
end

Private Instance Methods

genealogy_prefix() click to toggle source
# File lib/storexplore/walker.rb, line 81
def genealogy_prefix
  if father.nil?
    ""
  else
    father.genealogy + "\n"
  end
end
page() click to toggle source
# File lib/storexplore/walker.rb, line 77
def page
  @page ||= @getter.get
end
scrap_attributes() click to toggle source
# 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