Class: CatalogPage
- Inherits:
-
ItemsPage
- Object
- ServiceCall
- Page
- ItemsPage
- CatalogPage
- Defined in:
- lib/etvnet_seek/core/catalog_page.rb
Direct Known Subclasses
Constant Summary collapse
- CATALOG_URL =
BASE_URL + "/catalog/"
Constants inherited from Page
Instance Attribute Summary
Attributes inherited from Page
Attributes inherited from ServiceCall
Instance Method Summary collapse
-
#initialize(url = CATALOG_URL) ⇒ CatalogPage
constructor
A new instance of CatalogPage.
- #items ⇒ Object
Methods inherited from ItemsPage
#categories, #category_breadcrumbs, #description, #navigation_menu, #page_browser, #page_title, #see_too_items, #title, #title_items
Methods inherited from ServiceCall
Constructor Details
#initialize(url = CATALOG_URL) ⇒ CatalogPage
Returns a new instance of CatalogPage.
4 5 6 |
# File 'lib/etvnet_seek/core/catalog_page.rb', line 4 def initialize url = CATALOG_URL super(url) end |
Instance Method Details
#items ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/etvnet_seek/core/catalog_page.rb', line 8 def items list = [] document.css(".conteiner #results #table-onecolumn tr").each_with_index do |item, index| next if index == 0 showtime = item.css("td[1]").text.strip = item.css("td[3] img").at(0) ? item.css("td[3] img").at(0).attributes['src'].value.strip : "" = item.css("td[4]") ? item.css("td[4]").text.strip : "" name = item.css("td[2]").text.strip duration = item.css("td[5]") ? item.css("td[5]").text.strip : "" link = item.css("td[2] a").at(0) unless link.nil? href = link.attributes['href'].value digit_scan = name.scan(/\((\d*).*\)/)[0] amount_expr = digit_scan.nil? ? 0 : digit_scan[0].to_i folder = (amount_expr > 1) ? true : false record = BrowseMediaItem.new(name, href) record.folder = folder record.showtime = showtime record.duration = duration record. = record. = list << record end end list end |