Class: IntermatScrape::WeightClass
- Inherits:
-
Object
- Object
- IntermatScrape::WeightClass
- Defined in:
- lib/intermat_scrape/weight_class.rb
Constant Summary collapse
- WEIGHT_CLASSES =
%w[125 133 141 149 157 165 174 184 197 Hwt].freeze
- @@all =
[]
Instance Attribute Summary collapse
-
#weight ⇒ Object
Returns the value of attribute weight.
-
#wrestlers ⇒ Object
Returns the value of attribute wrestlers.
Class Method Summary collapse
- .all ⇒ Object
- .create_weight_classes ⇒ Object
- .find_by_weight(weight) ⇒ Object
- .print_weights ⇒ Object
Instance Method Summary collapse
- #add_wrestler(wrestler) ⇒ Object
-
#get_wrestler_by_rank(rank) ⇒ Object
TODO: move to Wrestler class?.
-
#initialize(weight) ⇒ WeightClass
constructor
A new instance of WeightClass.
-
#print_wrestlers ⇒ Object
TODO: move to Wrestler class?.
Constructor Details
#initialize(weight) ⇒ WeightClass
Returns a new instance of WeightClass.
8 9 10 11 12 |
# File 'lib/intermat_scrape/weight_class.rb', line 8 def initialize(weight) @weight = weight @wrestlers = [] @@all << self end |
Instance Attribute Details
#weight ⇒ Object
Returns the value of attribute weight.
2 3 4 |
# File 'lib/intermat_scrape/weight_class.rb', line 2 def weight @weight end |
#wrestlers ⇒ Object
Returns the value of attribute wrestlers.
2 3 4 |
# File 'lib/intermat_scrape/weight_class.rb', line 2 def wrestlers @wrestlers end |
Class Method Details
.all ⇒ Object
46 47 48 |
# File 'lib/intermat_scrape/weight_class.rb', line 46 def self.all @@all end |
.create_weight_classes ⇒ Object
14 15 16 17 18 19 |
# File 'lib/intermat_scrape/weight_class.rb', line 14 def self.create_weight_classes WEIGHT_CLASSES.each do |weight| new(weight) end @@all end |
.find_by_weight(weight) ⇒ Object
25 26 27 |
# File 'lib/intermat_scrape/weight_class.rb', line 25 def self.find_by_weight(weight) @@all.detect { |w| w.weight == weight } end |
.print_weights ⇒ Object
21 22 23 |
# File 'lib/intermat_scrape/weight_class.rb', line 21 def self.print_weights puts WEIGHT_CLASSES end |
Instance Method Details
#add_wrestler(wrestler) ⇒ Object
29 30 31 32 |
# File 'lib/intermat_scrape/weight_class.rb', line 29 def add_wrestler(wrestler) @wrestlers << wrestler wrestler.weight_class = self end |
#get_wrestler_by_rank(rank) ⇒ Object
TODO: move to Wrestler class?
42 43 44 |
# File 'lib/intermat_scrape/weight_class.rb', line 42 def get_wrestler_by_rank(rank) @wrestlers.detect { |w| w.rank == rank } end |
#print_wrestlers ⇒ Object
TODO: move to Wrestler class?
35 36 37 38 39 |
# File 'lib/intermat_scrape/weight_class.rb', line 35 def print_wrestlers puts "" puts "Rankings: ".colorize(:light_cyan) @wrestlers.each.with_index { |w, _i| puts "#{w.rank}\t#{w.name}" } end |