Class: MotionBlender::Analyzer::OriginalFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/motion_blender/analyzer/original_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ OriginalFinder

Returns a new instance of OriginalFinder.



6
7
8
# File 'lib/motion_blender/analyzer/original_finder.rb', line 6

def initialize file
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



4
5
6
# File 'lib/motion_blender/analyzer/original_finder.rb', line 4

def file
  @file
end

#originalObject (readonly)

Returns the value of attribute original.



4
5
6
# File 'lib/motion_blender/analyzer/original_finder.rb', line 4

def original
  @original
end

Instance Method Details

#candidates_for(arg) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/motion_blender/analyzer/original_finder.rb', line 17

def candidates_for arg
  Enumerator.new do |y|
    $LOAD_PATH.each do |dir|
      y << Pathname.new(dir).join(arg)
    end
  end
end

#findObject



10
11
12
13
14
15
# File 'lib/motion_blender/analyzer/original_finder.rb', line 10

def find
  dir = MotionBlender.config.motion_dirs.find { |d| @file.start_with? d }
  fail 'not found in motion_dirs' unless dir
  arg = Pathname.new(@file).relative_path_from(Pathname.new(dir))
  @original = candidates_for(arg).find(&:file?).try(&:to_s)
end