Class: LCSP::LCSPResolver
- Inherits:
-
Object
- Object
- LCSP::LCSPResolver
- Defined in:
- lib/lcsp/resolver.rb
Overview
LCSPResolver logic.
Instance Method Summary collapse
-
#initialize(user, repository, number) ⇒ LCSPResolver
constructor
LCSPResolver is entry point for any LCSP request by user.
-
#resolve ⇒ String?
Resolves the LCSP by creating an LCSPCache instance, locating the LCSPFinder file, requiring it, and then creating an LCSPFinder instance to find the solution.
Constructor Details
#initialize(user, repository, number) ⇒ LCSPResolver
LCSPResolver is entry point for any LCSP request by user.
13 14 15 16 17 |
# File 'lib/lcsp/resolver.rb', line 13 def initialize(user, repository, number) @user = user @repository = repository @number = number end |
Instance Method Details
#resolve ⇒ String?
Resolves the LCSP by creating an LCSPCache instance, locating the LCSPFinder file, requiring it, and then creating an LCSPFinder instance to find the solution.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lcsp/resolver.rb', line 24 def resolve cache = ::LCSP::LCSPCache.new(@user, @repository) finder_path = "#{cache.path}/lcsp/finder.rb" unless ::File.exist?(finder_path) puts('finder.rb not found in repository. Please, check config and try again.') exit(1) end require_relative(finder_path) solution = ::LCSP::LCSPFinder.new(cache.path, @number).solution if solution.nil? puts('Solution not found. Please, check your input and try again.') exit(2) end solution end |