Module: FilepathList::EntriesMethods
- Included in:
- FilepathList
- Defined in:
- lib/filepath/filepathlist.rb
Instance Method Summary collapse
- #exclude(pattern = nil, &block) ⇒ Object
- #map(&block) ⇒ Object
- #select(pattern = nil, &block) ⇒ Object
Instance Method Details
#exclude(pattern = nil, &block) ⇒ Object
146 147 148 149 150 151 152 |
# File 'lib/filepath/filepathlist.rb', line 146 def exclude(pattern = nil, &block) if block_given? select { |e| !block.call(e) } else select { |e| !(e =~ pattern) } end end |
#map(&block) ⇒ Object
131 132 133 134 |
# File 'lib/filepath/filepathlist.rb', line 131 def map(&block) mapped_entries = @entries.map(&block) return FilepathList.new(mapped_entries) end |
#select(pattern = nil, &block) ⇒ Object
136 137 138 139 140 141 142 143 144 |
# File 'lib/filepath/filepathlist.rb', line 136 def select(pattern = nil, &block) if !block_given? block = proc { |e| e =~ pattern } end remaining_entries = @entries.select { |e| block.call(e) } return FilepathList.new(remaining_entries) end |