Class: Weneedfeed::Page

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description:, item_description_selector:, item_image_selector:, item_link_selector:, item_time_selector:, item_title_selector:, item_selector:, node:, title:, url:) ⇒ Page

Returns a new instance of Page.

Parameters:

  • description (String, nil)
  • item_description_selector (String, nil)
  • item_image_selector (String, nil)
  • item_link_selector (String)
  • item_time_selector (String, nil)
  • item_title_selector (String)
  • item_selector (String)
  • node (Nokogiri::Node)
  • title (String)
  • url (String)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/weneedfeed/page.rb', line 24

def initialize(
  description:,
  item_description_selector:,
  item_image_selector:,
  item_link_selector:,
  item_time_selector:,
  item_title_selector:,
  item_selector:,
  node:,
  title:,
  url:
)
  @description = description
  @item_description_selector = item_description_selector
  @item_image_selector = item_image_selector
  @item_link_selector = item_link_selector
  @item_time_selector = item_time_selector
  @item_title_selector = item_title_selector
  @item_selector = item_selector
  @node = node
  @title = title
  @url = url
end

Instance Attribute Details

#descriptionString? (readonly)

Returns:

  • (String, nil)


6
7
8
# File 'lib/weneedfeed/page.rb', line 6

def description
  @description
end

#titleString (readonly)

Returns:

  • (String)


9
10
11
# File 'lib/weneedfeed/page.rb', line 9

def title
  @title
end

#urlString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/weneedfeed/page.rb', line 12

def url
  @url
end

Instance Method Details

#itemsArray<Weneedfeed::Item>

Returns:



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/weneedfeed/page.rb', line 49

def items
  @node.search(@item_selector).map do |node|
    ::Weneedfeed::Item.new(
      description_selector: @item_description_selector,
      image_selector: @item_image_selector,
      link_selector: @item_link_selector,
      node: node,
      time_selector: @item_time_selector,
      title_selector: @item_title_selector,
      url: @url
    )
  end
end