Class: Craig::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/craig/page.rb

Overview

Represents a page of listings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(category, subcategory, dom) ⇒ Page

Returns a new instance of Page.



7
8
9
10
11
# File 'lib/craig/page.rb', line 7

def initialize(category, subcategory, dom)
  @category = category
  @subcategory = subcategory
  @dom = dom
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



5
6
7
# File 'lib/craig/page.rb', line 5

def category
  @category
end

#domObject (readonly)

Returns the value of attribute dom.



5
6
7
# File 'lib/craig/page.rb', line 5

def dom
  @dom
end

#subcategoryObject (readonly)

Returns the value of attribute subcategory.



5
6
7
# File 'lib/craig/page.rb', line 5

def subcategory
  @subcategory
end

Instance Method Details

#listingsArray<Craig::Listing>

Returns:



14
15
16
17
18
# File 'lib/craig/page.rb', line 14

def listings
  dom.css("#toc_rows .row").map do |node|
    listing_const.new(node)
  end
end