Class: Lotus::Utils::LoadPaths
- Inherits:
-
Object
- Object
- Lotus::Utils::LoadPaths
- Defined in:
- lib/lotus/utils/load_paths.rb
Overview
A collection of loading paths.
Instance Method Summary collapse
- #==(other) ⇒ Object private
-
#each {|pathname| ... } ⇒ void
Iterates thru the collection and yields the given block.
-
#freeze ⇒ Object
It freezes the object by preventing further modifications.
-
#initialize(*paths) ⇒ Lotus::Utils::LoadPaths
constructor
Initialize a new collection for the given paths.
-
#initialize_copy(original) ⇒ Object
private
It specifies the policy for initialize copies of the object, when #clone or #dup are invoked.
-
#push(*paths) ⇒ Lotus::Utils::LoadPaths
(also: #<<)
Adds the given path(s).
Constructor Details
#initialize(*paths) ⇒ Lotus::Utils::LoadPaths
Initialize a new collection for the given paths
20 21 22 |
# File 'lib/lotus/utils/load_paths.rb', line 20 def initialize(*paths) @paths = Utils::Kernel.Array(paths) end |
Instance Method Details
#==(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
142 143 144 145 146 147 148 149 |
# File 'lib/lotus/utils/load_paths.rb', line 142 def ==(other) case other when self.class other.paths == paths else other == paths end end |
#each {|pathname| ... } ⇒ void
This method returns an undefined value.
Iterates thru the collection and yields the given block. It skips duplications and raises an error in case one of the paths doesn’t exist.
63 64 65 66 67 |
# File 'lib/lotus/utils/load_paths.rb', line 63 def each @paths.each do |path| yield realpath(path) end end |
#freeze ⇒ Object
It freezes the object by preventing further modifications.
135 136 137 138 |
# File 'lib/lotus/utils/load_paths.rb', line 135 def freeze super @paths.freeze end |
#initialize_copy(original) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
It specifies the policy for initialize copies of the object, when #clone or #dup are invoked.
47 48 49 |
# File 'lib/lotus/utils/load_paths.rb', line 47 def initialize_copy(original) @paths = original.instance_variable_get(:@paths).dup end |
#push(*paths) ⇒ Lotus::Utils::LoadPaths Also known as: <<
Adds the given path(s).
It returns self, so that multiple operations can be performed.
112 113 114 115 116 |
# File 'lib/lotus/utils/load_paths.rb', line 112 def push(*paths) @paths.push(*paths) @paths = Kernel.Array(@paths) self end |