Module: XblGamercard::MicroScraper
- Included in:
- Gamercard, GamercardGame, LiveProfile
- Defined in:
- lib/xbl_gamercard/micro_scraper.rb
Overview
Really simple scraper DSL for objects that have a root node and want to extract data from the root node’s children.
The class must have a method called ‘element` that returns the root node.
The various extract methods all take a CSS selector, and optionally a hash of options and a block. The block is applied to the first node (for extract methods), or mapped to each node (for extract_all methods).
Options are:
-
:as
- The name of the method that is generated. -
:from
- The name of the method that returns the root element.class XblGamercard
include XblGamercard::Microscraper # The following are all equivalent extract("#Gamertag", :as => "gamertag") { |e| e.text } extract_text "#Gamertag" extract_int "#Gamerscore" extract_text("#Gamerscore", &:to_i) extract("#Gamerscore") { |e| e.text.to_i }
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
79 80 81 |
# File 'lib/xbl_gamercard/micro_scraper.rb', line 79 def self.included(base) base.extend(ClassMethods) end |