class Scrapula::Page

Public Class Methods

new(agent_page) click to toggle source
# File lib/scrapula/page.rb, line 4
def initialize agent_page
  @agent_page = agent_page
end

Public Instance Methods

at!(query, operations = []) { |result| ... } click to toggle source

at returns the first one only, but search returns all TODO merge with search!

# File lib/scrapula/page.rb, line 39
def at! query, operations = [], &block
  result = @agent_page.at query
  result = operations.reduce(result) {|tmp, op| tmp.__send__ op } if result

  yield result if block_given?

  result
end
date!(query, format, operations = [], &block) click to toggle source
# File lib/scrapula/page.rb, line 79
def date! query, format, operations = [], &block
end
datetime!(query, format, operations = [], &block) click to toggle source
# File lib/scrapula/page.rb, line 76
def datetime! query, format, operations = [], &block
end
decimal!(query, operations = [], &block) click to toggle source
# File lib/scrapula/page.rb, line 73
def decimal! query, operations = [], &block
end
html!(query, operations = [], &block) click to toggle source

TODO def attribute! query, name, operations = [], &block end

# File lib/scrapula/page.rb, line 52
def html! query, operations = [], &block
  operations.unshift :to_html
  at! query, operations, &block
end
int!(query, re, operations = [], &block) click to toggle source
# File lib/scrapula/page.rb, line 70
def int! query, re, operations = [], &block
end
meta!() click to toggle source
# File lib/scrapula/page.rb, line 18
def meta!
  @meta ||= Meta.new self
end
Also aliased as: metas!
metas!()
Alias for: meta!
re!(query, re, operations = [], &block)
Alias for: regex!
regex!(query, re, operations = [], &block) click to toggle source

TODO xhtml! (to_xhtml) ? TODO inner_html / inner_text ?

# File lib/scrapula/page.rb, line 66
def regex! query, re, operations = [], &block
end
Also aliased as: re!
scrape(&block) click to toggle source

TODO def url!

@agent_page.url

end

# File lib/scrapula/page.rb, line 13
def scrape &block
  scraper = Scrapula::Scraper.new self, &block
  scraper.data!
end
search!(query, operations = []) { |result| ... } click to toggle source

at returns the first one only, but search returns all

# File lib/scrapula/page.rb, line 24
def search! query, operations = [], &block
  result = @agent_page.search query

  # FIXME on every object
  result = operations.reduce(result) do |tmp, op|
    tmp.__send__ op
  end if result

  yield result if block_given?

  result
end
text!(query, operations = [], &block) click to toggle source
# File lib/scrapula/page.rb, line 57
def text! query, operations = [], &block
  operations.unshift :text
  at! query, operations, &block
end
Also aliased as: txt!
time!(query, format, operations = [], &block) click to toggle source
# File lib/scrapula/page.rb, line 82
def time! query, format, operations = [], &block
end
txt!(query, operations = [], &block)
Alias for: text!