Class: Belajar::ReferenceSolution

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathObject (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

#codeObject



10
11
12
# File 'lib/belajar/reference_solution.rb', line 10

def code
  @code.to_s
end

#code_linesObject



14
15
16
# File 'lib/belajar/reference_solution.rb', line 14

def code_lines
  code.lines.map(&:chomp)
end