class ScrapCbf
ScrapCbf
is a gem created for scraping data from the CBF official page. Some of the data found on the CBF page are: teams, matches, rounds and ranking table from all championships founded on the official page.
Constants
- VERSION
Attributes
championship[R]
document[R]
@!attribute [r] document
@return [ScrapCbf::Document] ScrapCbf::Document instance.
@!attribute [r] championship
@return [ScrapCbf::Championship] ScrapCbf::Championship instance.
Public Class Methods
new(opts = {})
click to toggle source
@param [Hash] opts @option opts [Integer] :year The Championship
year. @option opts [Symbol] :serie The Championship
serie. @option opts [Symbol] :load_from_sample Load championship from sample. @option opts [Symbol] :sample_path to the sample otherwise default
@return [ScrapCbf] new instance
# File lib/scrap_cbf.rb, line 52 def initialize(opts = {}) year = opts.fetch(:year, Date.today.year.to_i) serie = opts.fetch(:serie, :serie_a) @document = Document.new(year, serie, opts) @parsed_document = @document.parsed_document @championship = Championship.new(year, serie) end
Public Instance Methods
matches()
click to toggle source
@return [MatchesBuilder] instance.
# File lib/scrap_cbf.rb, line 74 def matches @matches ||= rounds.matches_builder end
rankings()
click to toggle source
@return [RankingsBuilder] instance.
# File lib/scrap_cbf.rb, line 79 def rankings @rankings ||= RankingsBuilder.new(@parsed_document, @championship) end
rounds()
click to toggle source
@return [RoundsBuilder] instance.
# File lib/scrap_cbf.rb, line 84 def rounds @rounds ||= RoundsBuilder.new(@parsed_document, @championship) end
teams()
click to toggle source
@return [TeamsBuilder] instance.
# File lib/scrap_cbf.rb, line 89 def teams @teams ||= TeamsBuilder.new(@parsed_document) end
to_h()
click to toggle source
returns all entities scraped in hash format.
# File lib/scrap_cbf.rb, line 62 def to_h { championship: championship.to_h, matches: matches.to_h, rankings: rankings.to_h, rounds: rounds.to_h, teams: teams.to_h }.with_indifferent_access end