Class: TDRB::Performance
- Inherits:
-
Object
- Object
- TDRB::Performance
- Defined in:
- lib/tdrb/performance.rb
Instance Attribute Summary collapse
-
#fails ⇒ Object
Returns the value of attribute fails.
-
#load ⇒ Object
Returns the value of attribute load.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#movement ⇒ Object
Returns the value of attribute movement.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#reps ⇒ Object
Returns the value of attribute reps.
-
#sequence ⇒ Object
Returns the value of attribute sequence.
-
#sets ⇒ Object
Returns the value of attribute sets.
Instance Method Summary collapse
- #==(p) ⇒ Object
-
#initialize(fails: 0, load: nil, movement: "Unidentified Movement", metadata: {}, notes: [], reps: 1, sequence: 0, sets: 1) ⇒ Performance
constructor
A new instance of Performance.
- #to_h ⇒ Object
- #to_json ⇒ Object
- #volume ⇒ Object
Constructor Details
#initialize(fails: 0, load: nil, movement: "Unidentified Movement", metadata: {}, notes: [], reps: 1, sequence: 0, sets: 1) ⇒ Performance
Returns a new instance of Performance.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tdrb/performance.rb', line 12 def initialize( fails: 0, load: nil, movement: "Unidentified Movement", metadata: {}, notes: [], reps: 1, sequence: 0, sets: 1 ) @fails = 0 @load = load @movement = movement @metadata = @notes = notes @reps = 1 @sequence = 0 @sets = 1 end |
Instance Attribute Details
#fails ⇒ Object
Returns the value of attribute fails.
3 4 5 |
# File 'lib/tdrb/performance.rb', line 3 def fails @fails end |
#load ⇒ Object
Returns the value of attribute load.
3 4 5 |
# File 'lib/tdrb/performance.rb', line 3 def load @load end |
#metadata ⇒ Object
Returns the value of attribute metadata.
3 4 5 |
# File 'lib/tdrb/performance.rb', line 3 def @metadata end |
#movement ⇒ Object
Returns the value of attribute movement.
3 4 5 |
# File 'lib/tdrb/performance.rb', line 3 def movement @movement end |
#notes ⇒ Object
Returns the value of attribute notes.
3 4 5 |
# File 'lib/tdrb/performance.rb', line 3 def notes @notes end |
#reps ⇒ Object
Returns the value of attribute reps.
3 4 5 |
# File 'lib/tdrb/performance.rb', line 3 def reps @reps end |
#sequence ⇒ Object
Returns the value of attribute sequence.
3 4 5 |
# File 'lib/tdrb/performance.rb', line 3 def sequence @sequence end |
#sets ⇒ Object
Returns the value of attribute sets.
3 4 5 |
# File 'lib/tdrb/performance.rb', line 3 def sets @sets end |
Instance Method Details
#==(p) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/tdrb/performance.rb', line 32 def ==(p) raise TypeError.new("Not a Performance") if !p.is_a? Performance p.movement == movement && p.reps == reps && p.sets == sets && p.fails == fails && p.load == load end |
#to_h ⇒ Object
42 43 44 45 46 47 |
# File 'lib/tdrb/performance.rb', line 42 def to_h @hash ||= instance_variables.each_with_object({}) do |iv, h| h[iv[1..].to_sym] = instance_variable_get(iv) end end |
#to_json ⇒ Object
49 50 51 |
# File 'lib/tdrb/performance.rb', line 49 def to_json @json ||= to_h.to_json end |
#volume ⇒ Object
53 54 55 |
# File 'lib/tdrb/performance.rb', line 53 def volume (load || 0.0) * sets * (reps - fails) end |