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