Module: ROM::Files::Dataset::Paths

Included in:
ROM::Files::Dataset
Defined in:
lib/rom/files/dataset/paths.rb

Defined Under Namespace

Modules: ClassInterface

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#row_procProc (readonly)

Returns:

  • (Proc)


# File 'lib/rom/files/dataset/paths.rb', line 22

Class Method Details

.included(other) ⇒ Object



10
11
12
13
# File 'lib/rom/files/dataset/paths.rb', line 10

def self.included(other)
  super(other)
  other.extend ClassInterface
end

Instance Method Details

#countInteger

Returns:

  • (Integer)


73
74
75
# File 'lib/rom/files/dataset/paths.rb', line 73

def count
  to_a.size
end

#dataArray<Hash{Symbol => Pathname, String}> Also known as: to_a

Returns:

  • (Array<Hash{Symbol => Pathname, String}>)


55
56
57
# File 'lib/rom/files/dataset/paths.rb', line 55

def data
  pluck(row_proc)
end

#eachEnumerator, Array

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.

Iterate over data using row_proc

Returns:

  • (Enumerator, Array)

    if block is not given



67
68
69
70
# File 'lib/rom/files/dataset/paths.rb', line 67

def each
  return to_enum unless block_given?
  paths.each { |tuple| yield(row_proc[tuple]) }
end

#pathsArray<Pathname>

Returns:



26
27
28
# File 'lib/rom/files/dataset/paths.rb', line 26

def paths
  connection.search(search_patterns, exclude_patterns: exclude_patterns, sorting: sorting, path: path)
end

#pluck(field) ⇒ Array #pluck({ |pathname| ... }) ⇒ Array

Pluck values from a pathname property

Examples:

Usage with Symbol

users.pluck(:extname).uniq
# %w[.rb .rbw]

Usage with block

users.pluck { |pathname| pathname.basename.to_s }
# [1, 2, 3]

Parameters:

  • field (#to_proc, nil) (defaults to: nil)

    A name of the property for extracting values from pathname

Returns:

  • (Array)


49
50
51
52
# File 'lib/rom/files/dataset/paths.rb', line 49

def pluck(field = nil, &block)
  block ||= field&.to_proc || row_proc
  paths.map(&block)
end