Class: WindowsPathArray
- Inherits:
-
Array
- Object
- Array
- WindowsPathArray
- Defined in:
- lib/windows_path.rb
Overview
Specialized array that knows how to compare paths.
Instance Method Summary collapse
- #<<(p) ⇒ Object (also: #add)
- #[](idx) ⇒ Object
- #compare_paths(left, right) ⇒ Object
- #delete(path) ⇒ Object
- #each ⇒ Object
- #include?(path) ⇒ Boolean
-
#raw_item ⇒ Object
Preserve access to base class definition of [].
Instance Method Details
#<<(p) ⇒ Object Also known as: add
20 21 22 |
# File 'lib/windows_path.rb', line 20 def <<(p) super(p.to_s) end |
#[](idx) ⇒ Object
39 40 41 |
# File 'lib/windows_path.rb', line 39 def [](idx) WindowsPath.(super) end |
#compare_paths(left, right) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/windows_path.rb', line 13 def compare_paths(left, right) left = Pathname.new(WindowsPath.(left.to_s).downcase).cleanpath right = Pathname.new(WindowsPath.(right.to_s).downcase).cleanpath return left.eql?(right) end |
#delete(path) ⇒ Object
26 27 28 |
# File 'lib/windows_path.rb', line 26 def delete(path) self.delete_if { |p| compare_paths(path, p) } end |
#each ⇒ Object
30 31 32 33 34 |
# File 'lib/windows_path.rb', line 30 def each for i in 0..size - 1 yield WindowsPath.(raw_item(i)) end end |
#include?(path) ⇒ Boolean
7 8 9 10 11 |
# File 'lib/windows_path.rb', line 7 def include?(path) # Compare paths case-insensitive, and also checking # trailing separators (so c:\program files == c:\program files\) self.any? { |p| compare_paths(path, p) } end |
#raw_item ⇒ Object
Preserve access to base class definition of []
37 |
# File 'lib/windows_path.rb', line 37 alias_method :raw_item, :[] |