Class: Workout
- Inherits:
-
Object
- Object
- Workout
- Defined in:
- lib/workout.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#creation_date ⇒ Object
Returns the value of attribute creation_date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#workout_hash ⇒ Object
Returns the value of attribute workout_hash.
Class Method Summary collapse
Instance Method Summary collapse
- #add_selected_to_current_workout(exr) ⇒ Object
- #hash_workout ⇒ Object
-
#initialize(id, comments = nil, creation_date = Time.new.strftime("%Y-%m-%d")) ⇒ Workout
constructor
A new instance of Workout.
- #session_exercises ⇒ Object
- #set_exercise_array ⇒ Object
Constructor Details
#initialize(id, comments = nil, creation_date = Time.new.strftime("%Y-%m-%d")) ⇒ Workout
Returns a new instance of Workout.
8 9 10 11 12 13 14 15 |
# File 'lib/workout.rb', line 8 def initialize(id, comments=nil, creation_date=Time.new.strftime("%Y-%m-%d")) @id = id @comments = comments @creation_date = creation_date @@all << self @exercises = [] @workout_hash = self.hash_workout end |
Instance Attribute Details
#comments ⇒ Object
Returns the value of attribute comments.
2 3 4 |
# File 'lib/workout.rb', line 2 def comments @comments end |
#creation_date ⇒ Object
Returns the value of attribute creation_date.
2 3 4 |
# File 'lib/workout.rb', line 2 def creation_date @creation_date end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/workout.rb', line 2 def id @id end |
#workout_hash ⇒ Object
Returns the value of attribute workout_hash.
2 3 4 |
# File 'lib/workout.rb', line 2 def workout_hash @workout_hash end |
Class Method Details
.all ⇒ Object
22 23 24 |
# File 'lib/workout.rb', line 22 def self.all @@all end |
Instance Method Details
#add_selected_to_current_workout(exr) ⇒ Object
26 27 28 |
# File 'lib/workout.rb', line 26 def add_selected_to_current_workout(exr) exr.workout = self end |
#hash_workout ⇒ Object
17 18 19 20 |
# File 'lib/workout.rb', line 17 def hash_workout workout_hash = Hash.new workout_hash = {:id => id, :comments => comments, :creation_date => creation_date} end |
#session_exercises ⇒ Object
30 31 32 |
# File 'lib/workout.rb', line 30 def session_exercises @exercises = Exercise.all.select { |exr| exr.workout == self } end |
#set_exercise_array ⇒ Object
34 35 36 37 38 39 |
# File 'lib/workout.rb', line 34 def set_exercise_array exercises = self.session_exercises match = self.session_exercises.find { |exr| exr.muscle == "Abs" } match_index = self.session_exercises.index(match) exercises = exercises.insert(-1,exercises.delete_at(match_index)) end |