Class: ScrapCbf
- Inherits:
-
Object
- Object
- ScrapCbf
- Includes:
- Formattable, Printable
- Defined in:
- lib/scrap_cbf.rb,
lib/scrap_cbf/errors.rb,
lib/scrap_cbf/version.rb,
lib/scrap_cbf/document.rb,
lib/scrap_cbf/printable.rb,
lib/scrap_cbf/formattable.rb,
lib/scrap_cbf/models/team.rb,
lib/scrap_cbf/models/match.rb,
lib/scrap_cbf/models/round.rb,
lib/scrap_cbf/models/ranking.rb,
lib/scrap_cbf/models/table/row.rb,
lib/scrap_cbf/models/table/cell.rb,
lib/scrap_cbf/models/championship.rb,
lib/scrap_cbf/helpers/lib/findable.rb,
lib/scrap_cbf/helpers/teams_helper.rb,
lib/scrap_cbf/builders/teams_builder.rb,
lib/scrap_cbf/helpers/matches_helper.rb,
lib/scrap_cbf/builders/rounds_builder.rb,
lib/scrap_cbf/helpers/rankings_helper.rb,
lib/scrap_cbf/builders/matches_builder.rb,
lib/scrap_cbf/helpers/lib/depth_search.rb,
lib/scrap_cbf/builders/rankings_builder.rb,
lib/scrap_cbf/models/table/header_column.rb,
lib/scrap_cbf/helpers/lib/element_nokogiri.rb,
lib/scrap_cbf/builders/matches_per_round_builder.rb
Overview
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.
Defined Under Namespace
Modules: DepthSearch, ElementNokogiri, Findable, Formattable, MatchesHelper, Printable, RankingsHelper, TeamsHelper Classes: BaseError, Cell, Championship, Document, HeaderColumn, InvalidNumberOfEntitiesError, Match, MatchesBuilder, MatchesPerRoundBuilder, MethodMissingError, MethodNotImplementedError, MissingArgumentError, OutOfRangeArgumentError, Ranking, RankingsBuilder, Round, RoundsBuilder, Row, RowSizeError, Team, TeamsBuilder
Constant Summary collapse
- VERSION =
'0.1.0'
Instance Attribute Summary collapse
-
#championship ⇒ ScrapCbf::Championship
readonly
ScrapCbf::Championship instance.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ ScrapCbf
constructor
New instance.
-
#matches ⇒ MatchesBuilder
Instance.
-
#rankings ⇒ RankingsBuilder
Instance.
-
#rounds ⇒ RoundsBuilder
Instance.
-
#teams ⇒ TeamsBuilder
Instance.
-
#to_h ⇒ Object
returns all entities scraped in hash format.
Methods included from Printable
Methods included from Formattable
Constructor Details
#initialize(opts = {}) ⇒ ScrapCbf
Returns new instance.
52 53 54 55 56 57 58 59 |
# 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 |
Instance Attribute Details
#championship ⇒ ScrapCbf::Championship (readonly)
42 |
# File 'lib/scrap_cbf.rb', line 42 attr_reader :document |
#document ⇒ Object (readonly)
Returns the value of attribute document.
42 43 44 |
# File 'lib/scrap_cbf.rb', line 42 def document @document end |
Instance Method Details
#matches ⇒ MatchesBuilder
74 75 76 |
# File 'lib/scrap_cbf.rb', line 74 def matches @matches ||= rounds.matches_builder end |
#rankings ⇒ RankingsBuilder
79 80 81 |
# File 'lib/scrap_cbf.rb', line 79 def rankings @rankings ||= RankingsBuilder.new(@parsed_document, @championship) end |
#rounds ⇒ RoundsBuilder
84 85 86 |
# File 'lib/scrap_cbf.rb', line 84 def rounds @rounds ||= RoundsBuilder.new(@parsed_document, @championship) end |
#teams ⇒ TeamsBuilder
89 90 91 |
# File 'lib/scrap_cbf.rb', line 89 def teams @teams ||= TeamsBuilder.new(@parsed_document) end |
#to_h ⇒ Object
returns all entities scraped in hash format.
62 63 64 65 66 67 68 69 70 71 |
# 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 |