Class: Belajar::ReferenceSolution
- Inherits:
-
Object
- Object
- Belajar::ReferenceSolution
- Defined in:
- lib/belajar/reference_solution.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #code ⇒ Object
- #code_lines ⇒ Object
-
#initialize(path) ⇒ ReferenceSolution
constructor
A new instance of ReferenceSolution.
Constructor Details
#initialize(path) ⇒ ReferenceSolution
Returns a new instance of ReferenceSolution.
5 6 7 8 |
# File 'lib/belajar/reference_solution.rb', line 5 def initialize(path) @path = Dir[File.join(path, '*solution.rb')].first @code = File.read(@path).strip if @path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/belajar/reference_solution.rb', line 3 def path @path end |
Instance Method Details
#code ⇒ Object
10 11 12 |
# File 'lib/belajar/reference_solution.rb', line 10 def code @code.to_s end |
#code_lines ⇒ Object
14 15 16 |
# File 'lib/belajar/reference_solution.rb', line 14 def code_lines code.lines.map(&:chomp) end |