class ROM::Filesystem::Dataset
Public Class Methods
new(dir, options = {})
click to toggle source
# File lib/rom/filesystem/dataset.rb, line 4 def initialize(dir, options = {}) @dir = dir @options = options @options[:select] ||= ['*'] end
Public Instance Methods
each(&block)
click to toggle source
# File lib/rom/filesystem/dataset.rb, line 19 def each(&block) to_a.each(&block) end
select(*args)
click to toggle source
# File lib/rom/filesystem/dataset.rb, line 11 def select(*args) self.class.new(@dir, @options.merge(select: args)) end
sort()
click to toggle source
# File lib/rom/filesystem/dataset.rb, line 15 def sort self.class.new(@dir, @options.merge(sort: true)) end
to_a()
click to toggle source
# File lib/rom/filesystem/dataset.rb, line 23 def to_a root = Pathname.new(@dir.path) paths = @options[:select].map { |filter| "#{root}/#{filter}" } matches = Dir[*paths].reject { |f| f == '.' || f == '..' } matches = matches.sort if @options[:sort] matches.map do |filename| path = root.join(filename) { name: path.basename.to_s, path: path } end end