Class: SportDb::Import::EventInfo
- Inherits:
-
Object
- Object
- SportDb::Import::EventInfo
- Defined in:
- lib/sportdb/formats.rb,
lib/sportdb/formats/event/event_reader.rb
Instance Attribute Summary collapse
-
#end_date ⇒ Object
readonly
“high level” info (summary) about event (like a “wikipedia infobox”) use for checking dataset imports; lets you check e.g.
-
#goals ⇒ Object
readonly
“high level” info (summary) about event (like a “wikipedia infobox”) use for checking dataset imports; lets you check e.g.
-
#league ⇒ Object
readonly
“high level” info (summary) about event (like a “wikipedia infobox”) use for checking dataset imports; lets you check e.g.
-
#matches ⇒ Object
readonly
“high level” info (summary) about event (like a “wikipedia infobox”) use for checking dataset imports; lets you check e.g.
-
#season ⇒ Object
readonly
“high level” info (summary) about event (like a “wikipedia infobox”) use for checking dataset imports; lets you check e.g.
-
#start_date ⇒ Object
readonly
“high level” info (summary) about event (like a “wikipedia infobox”) use for checking dataset imports; lets you check e.g.
-
#teams ⇒ Object
readonly
“high level” info (summary) about event (like a “wikipedia infobox”) use for checking dataset imports; lets you check e.g.
Class Method Summary collapse
Instance Method Summary collapse
- #include?(date) ⇒ Boolean (also: #between?)
-
#initialize(league:, season:, start_date: nil, end_date: nil, teams: nil, matches: nil, goals: nil) ⇒ EventInfo
constructor
A new instance of EventInfo.
Constructor Details
#initialize(league:, season:, start_date: nil, end_date: nil, teams: nil, matches: nil, goals: nil) ⇒ EventInfo
Returns a new instance of EventInfo.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sportdb/formats/event/event_reader.rb', line 23 def initialize( league:, season:, start_date: nil, end_date: nil, teams: nil, matches: nil, goals: nil ) @league = league @season = season @start_date = start_date @end_date = end_date @teams = teams ## todo/check: rename/use teams_count ?? @matches = matches ## todo/check: rename/use match_count ?? @goals = goals end |
Instance Attribute Details
#end_date ⇒ Object (readonly)
“high level” info (summary) about event (like a “wikipedia infobox”)
use for checking dataset imports; lets you check e.g.
- dates within range
- number of teams e.g. 20
- matches played e.g. 380
- goals scored e.g. 937
etc.
15 16 17 |
# File 'lib/sportdb/formats/event/event_reader.rb', line 15 def end_date @end_date end |
#goals ⇒ Object (readonly)
“high level” info (summary) about event (like a “wikipedia infobox”)
use for checking dataset imports; lets you check e.g.
- dates within range
- number of teams e.g. 20
- matches played e.g. 380
- goals scored e.g. 937
etc.
15 16 17 |
# File 'lib/sportdb/formats/event/event_reader.rb', line 15 def goals @goals end |
#league ⇒ Object (readonly)
“high level” info (summary) about event (like a “wikipedia infobox”)
use for checking dataset imports; lets you check e.g.
- dates within range
- number of teams e.g. 20
- matches played e.g. 380
- goals scored e.g. 937
etc.
15 16 17 |
# File 'lib/sportdb/formats/event/event_reader.rb', line 15 def league @league end |
#matches ⇒ Object (readonly)
“high level” info (summary) about event (like a “wikipedia infobox”)
use for checking dataset imports; lets you check e.g.
- dates within range
- number of teams e.g. 20
- matches played e.g. 380
- goals scored e.g. 937
etc.
15 16 17 |
# File 'lib/sportdb/formats/event/event_reader.rb', line 15 def matches @matches end |
#season ⇒ Object (readonly)
“high level” info (summary) about event (like a “wikipedia infobox”)
use for checking dataset imports; lets you check e.g.
- dates within range
- number of teams e.g. 20
- matches played e.g. 380
- goals scored e.g. 937
etc.
15 16 17 |
# File 'lib/sportdb/formats/event/event_reader.rb', line 15 def season @season end |
#start_date ⇒ Object (readonly)
“high level” info (summary) about event (like a “wikipedia infobox”)
use for checking dataset imports; lets you check e.g.
- dates within range
- number of teams e.g. 20
- matches played e.g. 380
- goals scored e.g. 937
etc.
15 16 17 |
# File 'lib/sportdb/formats/event/event_reader.rb', line 15 def start_date @start_date end |
#teams ⇒ Object (readonly)
“high level” info (summary) about event (like a “wikipedia infobox”)
use for checking dataset imports; lets you check e.g.
- dates within range
- number of teams e.g. 20
- matches played e.g. 380
- goals scored e.g. 937
etc.
15 16 17 |
# File 'lib/sportdb/formats/event/event_reader.rb', line 15 def teams @teams end |
Class Method Details
.parse(txt) ⇒ Object
136 |
# File 'lib/sportdb/formats.rb', line 136 def self.parse( txt ) EventInfoReader.parse( txt ); end |
.read(path) ⇒ Object
135 |
# File 'lib/sportdb/formats.rb', line 135 def self.read( path ) EventInfoReader.read( path ); end |
Instance Method Details
#include?(date) ⇒ Boolean Also known as: between?
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/sportdb/formats/event/event_reader.rb', line 40 def include?( date ) ## todo/fix: add options e.g. ## - add delta/off_by_one or such? ## - add strict (for) only return true if date range (really) defined (no generic auto-rules) ### note: for now allow off by one error (via timezone/local time errors) ## todo/fix: issue warning if off by one!!!! if @start_date && @end_date date >= (@start_date-1) && date <= (@end_date+1) else if @season.year? # assume generic rule ## same year e.g. Jan 1 - Dec 31; always true for now date.year == @season.start_year else # assume generic rule ## July 1 - June 30 (Y+1) ## - todo/check -start for some countries/leagues in June 1 or August 1 ???? date >= Date.new( @season.start_year, 7, 1 ) && date <= Date.new( @season.end_year, 6, 30 ) end end end |