Class: ScrapCbf::Document
- Inherits:
-
Object
- Object
- ScrapCbf::Document
- Defined in:
- lib/scrap_cbf/document.rb
Overview
This class is responsible for:
-
Handler users input.
-
Fetch html page from CBF official page.
-
Parse html page with Nokogiri.
Constant Summary collapse
- URL =
'https://www.cbf.com.br/futebol-brasileiro/competicoes'- CHAMPIONSHIP_YEARS =
(2012..Date.today.year.to_i).to_a.freeze
- SERIES =
i[serie_a serie_b].freeze
- SERIES_PATH =
{ serie_a: 'campeonato-brasileiro-serie-a', serie_b: 'campeonato-brasileiro-serie-b' }.freeze
- SAMPLE_PATH =
"#{File.dirname(__FILE__)}/samples/" \ 'cbf_serie_a_2020.html'
Instance Attribute Summary collapse
-
#load_from_sample ⇒ Object
readonly
Returns the value of attribute load_from_sample.
-
#parsed_document ⇒ Object
readonly
Returns the value of attribute parsed_document.
-
#sample_path ⇒ Object
readonly
Returns the value of attribute sample_path.
-
#serie ⇒ Object
readonly
Returns the value of attribute serie.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(year, serie, opts) ⇒ Document
constructor
New instance.
Constructor Details
#initialize(year, serie, opts) ⇒ Document
Returns new instance.
42 43 44 45 46 47 48 49 50 |
# File 'lib/scrap_cbf/document.rb', line 42 def initialize(year, serie, opts) @year = year @serie = serie @load_from_sample = opts.fetch(:load_from_sample) { false } @sample_path = opts[:sample_path] @parsed_document = parse_document(year, serie, @load_from_sample, @sample_path) end |
Instance Attribute Details
#load_from_sample ⇒ Object (readonly)
Returns the value of attribute load_from_sample.
29 30 31 |
# File 'lib/scrap_cbf/document.rb', line 29 def load_from_sample @load_from_sample end |
#parsed_document ⇒ Object (readonly)
Returns the value of attribute parsed_document.
29 30 31 |
# File 'lib/scrap_cbf/document.rb', line 29 def parsed_document @parsed_document end |
#sample_path ⇒ Object (readonly)
Returns the value of attribute sample_path.
29 30 31 |
# File 'lib/scrap_cbf/document.rb', line 29 def sample_path @sample_path end |
#serie ⇒ Object (readonly)
Returns the value of attribute serie.
29 30 31 |
# File 'lib/scrap_cbf/document.rb', line 29 def serie @serie end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
29 30 31 |
# File 'lib/scrap_cbf/document.rb', line 29 def year @year end |
Class Method Details
.parse_document(year, serie, opts) ⇒ Object
24 25 26 |
# File 'lib/scrap_cbf/document.rb', line 24 def parse_document(year, serie, opts) new(year, serie, opts).parsed_document end |