Class: Kettle::Jem::FileWorkUnit

Inherits:
Object
  • Object
show all
Defined in:
lib/kettle/jem.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relative_path:, operations:) ⇒ FileWorkUnit

Returns a new instance of FileWorkUnit.

Raises:

  • (ArgumentError)


1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
# File 'lib/kettle/jem.rb', line 1805

def initialize(relative_path:, operations:)
  @relative_path = relative_path.to_s
  @operations = Array(operations)
  raise ArgumentError, "File work unit requires at least one operation" if @operations.empty?

  mismatched_paths = @operations.reject { |operation| operation.relative_path == @relative_path }
  return if mismatched_paths.empty?

  paths = mismatched_paths.map(&:relative_path).uniq.join(", ")
  raise ArgumentError, "File work unit #{relative_path.inspect} cannot include operations for #{paths}"
end

Instance Attribute Details

#operationsObject (readonly)

Returns the value of attribute operations.



1803
1804
1805
# File 'lib/kettle/jem.rb', line 1803

def operations
  @operations
end

#relative_pathObject (readonly)

Returns the value of attribute relative_path.



1803
1804
1805
# File 'lib/kettle/jem.rb', line 1803

def relative_path
  @relative_path
end

Instance Method Details

#outcomeObject



1817
1818
1819
# File 'lib/kettle/jem.rb', line 1817

def outcome
  operations.last
end