Class: MotionBlender::Analyzer::OriginalFinder
- Inherits:
-
Object
- Object
- MotionBlender::Analyzer::OriginalFinder
- Defined in:
- lib/motion_blender/analyzer/original_finder.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#original ⇒ Object
readonly
Returns the value of attribute original.
Instance Method Summary collapse
- #candidates_for(arg) ⇒ Object
- #find ⇒ Object
-
#initialize(file) ⇒ OriginalFinder
constructor
A new instance of OriginalFinder.
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
#file ⇒ Object (readonly)
Returns the value of attribute file.
4 5 6 |
# File 'lib/motion_blender/analyzer/original_finder.rb', line 4 def file @file end |
#original ⇒ Object (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 |
#find ⇒ Object
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 |