Class: PlayerSetHistory::Tournament
- Inherits:
-
Object
- Object
- PlayerSetHistory::Tournament
- Defined in:
- lib/player_set_history/tournament.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#name ⇒ Object
Returns the value of attribute name.
-
#sets ⇒ Object
Returns the value of attribute sets.
-
#winner ⇒ Object
Returns the value of attribute winner.
Class Method Summary collapse
Instance Method Summary collapse
- #add_set(set) ⇒ Object
-
#initialize(name, date) ⇒ Tournament
constructor
A new instance of Tournament.
Constructor Details
#initialize(name, date) ⇒ Tournament
Returns a new instance of Tournament.
7 8 9 10 11 12 |
# File 'lib/player_set_history/tournament.rb', line 7 def initialize (name, date) @name = name @date = DateTime.strptime(date.to_s,'%s').to_s[0..9] @@all << self @sets = [] end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
4 5 6 |
# File 'lib/player_set_history/tournament.rb', line 4 def date @date end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/player_set_history/tournament.rb', line 4 def name @name end |
#sets ⇒ Object
Returns the value of attribute sets.
4 5 6 |
# File 'lib/player_set_history/tournament.rb', line 4 def sets @sets end |
#winner ⇒ Object
Returns the value of attribute winner.
4 5 6 |
# File 'lib/player_set_history/tournament.rb', line 4 def winner @winner end |
Class Method Details
.all ⇒ Object
14 15 16 |
# File 'lib/player_set_history/tournament.rb', line 14 def self.all @@all end |
.find_or_create_from_name(name, date) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/player_set_history/tournament.rb', line 22 def self.find_or_create_from_name (name, date) tourny_index = self.all.index {|x| x.name == name} if tourny_index == nil tourny = PlayerSetHistory::Tournament.new(name, date) else tourny = self.all[tourny_index] end return tourny end |
Instance Method Details
#add_set(set) ⇒ Object
18 19 20 |
# File 'lib/player_set_history/tournament.rb', line 18 def add_set(set) @sets << set end |