Class: GScraper::Page
- Inherits:
-
Array
- Object
- Array
- GScraper::Page
- Defined in:
- lib/gscraper/page.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(elements = []) {|page| ... } ⇒ Page
constructor
Creates a new Page object.
-
#map {|element| ... } ⇒ Array, Enumerator
Maps the elements within the page.
-
#select {|element| ... } ⇒ Array, Enumerator
Selects the elements within the page.
Constructor Details
#initialize(elements = []) {|page| ... } ⇒ Page
Creates a new Page object.
36 37 38 39 40 |
# File 'lib/gscraper/page.rb', line 36 def initialize(elements=[]) super(elements) yield self if block_given? end |
Instance Method Details
#map {|element| ... } ⇒ Array, Enumerator
Maps the elements within the page.
60 61 62 63 64 65 66 67 |
# File 'lib/gscraper/page.rb', line 60 def map return enum_for(:map) unless block_given? mapped = [] each { |element| mapped << yield(element) } return mapped end |
#select {|element| ... } ⇒ Array, Enumerator
Selects the elements within the page.
82 83 84 85 86 87 88 |
# File 'lib/gscraper/page.rb', line 82 def select(&block) unless block enum_for(:select) else self.class.new(super(&block)) end end |