Class: Sports::Ground

Inherits:
Object
  • Object
show all
Defined in:
lib/sportdb/structs/ground.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ Ground

Returns a new instance of Ground.



60
61
62
63
64
# File 'lib/sportdb/structs/ground.rb', line 60

def initialize( **kwargs )
  @alt_names      = []

  update( **kwargs )  unless kwargs.empty?
end

Instance Attribute Details

#addressObject

todo: use just names for alt_names - why? why not?



11
12
13
# File 'lib/sportdb/structs/ground.rb', line 11

def address
  @address
end

#alt_namesObject

todo: use just names for alt_names - why? why not?



11
12
13
# File 'lib/sportdb/structs/ground.rb', line 11

def alt_names
  @alt_names
end

#cityObject

todo: use just names for alt_names - why? why not?



11
12
13
# File 'lib/sportdb/structs/ground.rb', line 11

def city
  @city
end

#countryObject

todo: use just names for alt_names - why? why not?



11
12
13
# File 'lib/sportdb/structs/ground.rb', line 11

def country
  @country
end

#districtObject

todo: use just names for alt_names - why? why not?



11
12
13
# File 'lib/sportdb/structs/ground.rb', line 11

def district
  @district
end

#geosObject

todo: use just names for alt_names - why? why not?



11
12
13
# File 'lib/sportdb/structs/ground.rb', line 11

def geos
  @geos
end

#keyObject

all names



11
12
13
# File 'lib/sportdb/structs/ground.rb', line 11

def key
  @key
end

#nameObject

todo: use just names for alt_names - why? why not?



11
12
13
# File 'lib/sportdb/structs/ground.rb', line 11

def name
  @name
end

#yearObject

todo: use just names for alt_names - why? why not?



11
12
13
# File 'lib/sportdb/structs/ground.rb', line 11

def year
  @year
end

#year_endObject

todo: use just names for alt_names - why? why not?



11
12
13
# File 'lib/sportdb/structs/ground.rb', line 11

def year_end
  @year_end
end

Instance Method Details

#historic?Boolean Also known as: past?

todo/check

check event_ifno  - for start_date, end_date ??
         use same naming convention here too (start_year/end_year)

Returns:

  • (Boolean)


56
# File 'lib/sportdb/structs/ground.rb', line 56

def historic?()  @year_end ? true : false; end

#namesObject



18
19
20
21
# File 'lib/sportdb/structs/ground.rb', line 18

def names
  ## todo/check: add alt_names_auto too? - why? why not?

  [@name] + @alt_names
end

#update(**kwargs) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/sportdb/structs/ground.rb', line 66

def update( **kwargs )
  @key         = kwargs[:key]        if kwargs.has_key?( :key )
  @name        = kwargs[:name]       if kwargs.has_key?( :name )
  @alt_names   = kwargs[:alt_names]  if kwargs.has_key?( :alt_names )

  @city        = kwargs[:city]       if kwargs.has_key?( :city )
  ## todo/fix:  use city struct - why? why not?

  ## todo/fix: add country too  or report unused keywords / attributes - why? why not?


  self   ## note - MUST return self for chaining

end