Class: Category

Inherits:
Object
  • Object
show all
Defined in:
lib/category.rb

Constant Summary collapse

@@all_categories =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCategory

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

#exercisesObject

Returns the value of attribute exercises.



2
3
4
# File 'lib/category.rb', line 2

def exercises
  @exercises
end

#muscleObject

Returns the value of attribute muscle.



2
3
4
# File 'lib/category.rb', line 2

def muscle
  @muscle
end

Class Method Details

.allObject



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_exercisesObject

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_exercisesObject

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