Class: Orthoses::PathHelper
- Inherits:
-
Object
- Object
- Orthoses::PathHelper
- Defined in:
- lib/orthoses/path_helper.rb
Class Method Summary collapse
Instance Method Summary collapse
- #best_version_paths ⇒ Object
- #find_best_version ⇒ Object
-
#initialize(current, base_dir) ⇒ PathHelper
constructor
A new instance of PathHelper.
- #version_dir ⇒ Object
Constructor Details
#initialize(current, base_dir) ⇒ PathHelper
Returns a new instance of PathHelper.
15 16 17 18 |
# File 'lib/orthoses/path_helper.rb', line 15 def initialize(current, base_dir) @current = current @base_dir = base_dir end |
Class Method Details
.best_version_paths(current, base_dir) ⇒ Object
10 11 12 |
# File 'lib/orthoses/path_helper.rb', line 10 def best_version_paths(current, base_dir) new(current, base_dir).best_version_paths end |
Instance Method Details
#best_version_paths ⇒ Object
20 21 22 23 |
# File 'lib/orthoses/path_helper.rb', line 20 def best_version_paths best_version = find_best_version Dir.glob("#{@base_dir}/#{best_version}/**/*.rbs") end |
#find_best_version ⇒ Object
25 26 27 28 29 |
# File 'lib/orthoses/path_helper.rb', line 25 def find_best_version current_v = Gem::Version.new(@current) versions = version_dir versions.reverse.bsearch { |v| v <= current_v } || versions.first end |
#version_dir ⇒ Object
31 32 33 34 35 36 |
# File 'lib/orthoses/path_helper.rb', line 31 def version_dir Dir.glob("#{@base_dir}/*") .map(&File.method(:basename)) .map(&Gem::Version.method(:new)) .sort end |