Class: Commands::Track::Exercise
- Inherits:
-
Object
- Object
- Commands::Track::Exercise
- Defined in:
- lib/commands/track/exercise.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#track ⇒ Object
readonly
Returns the value of attribute track.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #detail ⇒ Object
-
#initialize(track:, name:, path:) ⇒ Exercise
constructor
A new instance of Exercise.
- #name_error_msg ⇒ Object
- #path_error_msg ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(track:, name:, path:) ⇒ Exercise
Returns a new instance of Exercise.
6 7 8 9 10 |
# File 'lib/commands/track/exercise.rb', line 6 def initialize(track:, name:, path:) @track = track @name = name @path = path end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/commands/track/exercise.rb', line 4 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/commands/track/exercise.rb', line 4 def path @path end |
#track ⇒ Object (readonly)
Returns the value of attribute track.
4 5 6 |
# File 'lib/commands/track/exercise.rb', line 4 def track @track end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 |
# File 'lib/commands/track/exercise.rb', line 23 def ==(other) name == other.name && path == other.path end |
#detail ⇒ Object
12 13 14 |
# File 'lib/commands/track/exercise.rb', line 12 def detail "#{preamble}[Click here](../tree/master/#{path}) to read the #{name} exercise" end |
#name_error_msg ⇒ Object
31 32 33 |
# File 'lib/commands/track/exercise.rb', line 31 def name_error_msg 'Name not given for exercise' end |
#path_error_msg ⇒ Object
27 28 29 |
# File 'lib/commands/track/exercise.rb', line 27 def path_error_msg "Exercise: #{name} - not found at path: #{path}" end |
#validate ⇒ Object
16 17 18 19 20 21 |
# File 'lib/commands/track/exercise.rb', line 16 def validate raise ArgumentError, name_error_msg unless name raise ArgumentError, path_error_msg unless File.exist?(path) true end |