Class: Hike::Trail
- Inherits:
-
Object
- Object
- Hike::Trail
- Defined in:
- lib/hike/trail.rb
Instance Attribute Summary collapse
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #find(*logical_paths, &block) ⇒ Object
-
#initialize(root = ".") ⇒ Trail
constructor
A new instance of Trail.
Constructor Details
#initialize(root = ".") ⇒ Trail
Returns a new instance of Trail.
5 6 7 8 9 10 |
# File 'lib/hike/trail.rb', line 5 def initialize(root = ".") @root = File.(root) @index = DirectoryIndex.new @paths = Paths.new(@root) @extensions = Extensions.new end |
Instance Attribute Details
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
3 4 5 |
# File 'lib/hike/trail.rb', line 3 def extensions @extensions end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
3 4 5 |
# File 'lib/hike/trail.rb', line 3 def paths @paths end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
3 4 5 |
# File 'lib/hike/trail.rb', line 3 def root @root end |
Instance Method Details
#find(*logical_paths, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hike/trail.rb', line 12 def find(*logical_paths, &block) if block_given? = (logical_paths) base_path = [:base_path] || root reset! logical_paths.each do |logical_path| if relative?(logical_path) find_in_base_path(logical_path, base_path, &block) else find_in_paths(logical_path, &block) end end nil else find(*logical_paths) do |path| return path end end end |