Class: Category
- Inherits:
-
Object
- Object
- Category
- Defined in:
- lib/category.rb
Constant Summary collapse
- @@all_categories =
[]
Instance Attribute Summary collapse
-
#exercises ⇒ Object
Returns the value of attribute exercises.
-
#muscle ⇒ Object
Returns the value of attribute muscle.
Class Method Summary collapse
- .all ⇒ Object
- .get_exr_by_cat(user_input) ⇒ Object
-
.set_exercises ⇒ Object
sets what category instance of exercise object belongs to.
Instance Method Summary collapse
-
#get_exercises ⇒ Object
gets exercises belonging to an instance of Category.
-
#initialize ⇒ Category
constructor
A new instance of Category.
Constructor Details
#initialize ⇒ Category
Returns a new instance of Category.
5 6 7 8 |
# File 'lib/category.rb', line 5 def initialize @muscle = muscle @@all_categories << self end |
Instance Attribute Details
#exercises ⇒ Object
Returns the value of attribute exercises.
2 3 4 |
# File 'lib/category.rb', line 2 def exercises @exercises end |
#muscle ⇒ Object
Returns the value of attribute muscle.
2 3 4 |
# File 'lib/category.rb', line 2 def muscle @muscle end |
Class Method Details
.all ⇒ Object
10 11 12 |
# File 'lib/category.rb', line 10 def self.all @@all_categories end |
.get_exr_by_cat(user_input) ⇒ Object
28 29 30 31 |
# File 'lib/category.rb', line 28 def self.get_exr_by_cat(user_input) selected_category = self.all[user_input] selected_category.get_exercises end |
.set_exercises ⇒ Object
sets what category instance of exercise object belongs to
14 15 16 17 18 19 20 21 22 |
# File 'lib/category.rb', line 14 def self.set_exercises # sets what category instance of exercise object belongs to self.all.each do |category| Exercise.all.select do |exr| if category.muscle == exr.muscle exr.category = category end end end end |
Instance Method Details
#get_exercises ⇒ Object
gets exercises belonging to an instance of Category
24 25 26 |
# File 'lib/category.rb', line 24 def get_exercises # gets exercises belonging to an instance of Category Exercise.all.select { |exr| exr.category == self } end |