Module: Finder::Find::Base
Overview
Base module provides helper methods to other finders.
Class Method Summary collapse
-
.included(mod) ⇒ Object
When included into a module, that module is atuomatically self extended.
Instance Method Summary collapse
-
#append_extensions(match, options = {}) ⇒ Object
private
Append requirable extensions to match glob.
-
#feature(match, options = {}) ⇒ Object
Like #load_path but searches only for requirable feature files and returns relative paths by default.
-
#valid_load_options(options) ⇒ Object
private
Validate and normalize load options.
Class Method Details
.included(mod) ⇒ Object
When included into a module, that module is atuomatically self extended.
13 14 15 |
# File 'lib/finder/base.rb', line 13 def self.included(mod) mod.extend(mod) end |
Instance Method Details
#append_extensions(match, options = {}) ⇒ Object (private)
Append requirable extensions to match glob.
59 60 61 62 63 64 |
# File 'lib/finder/base.rb', line 59 def append_extensions(match, ={}) unless Find::EXTENSIONS.include?(File.extname(match)) match = match + '{' + Find::EXTENSIONS.join(',') + '}' end match end |
#feature(match, options = {}) ⇒ Object
Like #load_path but searches only for requirable feature files and returns relative paths by default.
32 33 34 35 36 |
# File 'lib/finder/base.rb', line 32 def feature(match, ={}) [:relative] = true unless .key?(:relative) or .key?(:absolute) match = append_extensions(match, ) load_path(match, ) end |
#valid_load_options(options) ⇒ Object (private)
Validate and normalize load options.
45 46 47 48 49 50 51 52 53 |
# File 'lib/finder/base.rb', line 45 def () if .key?(:relative) && .key?(:absolute) raise ArgumentError, "must be either relative or absolute" unless [:relative] ^ [:absolute] end [:relative] = false if [:absolute] end |