Class: Roast::ValueObjects::WorkflowPath

Inherits:
Object
  • Object
show all
Defined in:
lib/roast/value_objects/workflow_path.rb

Overview

Value object representing a workflow file path with validation and resolution

Defined Under Namespace

Classes: InvalidPathError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ WorkflowPath

Returns a new instance of WorkflowPath.



11
12
13
14
15
16
# File 'lib/roast/value_objects/workflow_path.rb', line 11

def initialize(path)
  @value = normalize_path(path)
  @pathname = Pathname.new(@value)
  validate!
  freeze
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/roast/value_objects/workflow_path.rb', line 9

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



46
47
48
49
50
# File 'lib/roast/value_objects/workflow_path.rb', line 46

def ==(other)
  return false unless other.is_a?(WorkflowPath)

  value == other.value
end

#absolute?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/roast/value_objects/workflow_path.rb', line 22

def absolute?
  pathname.absolute?
end

#basenameObject



34
35
36
# File 'lib/roast/value_objects/workflow_path.rb', line 34

def basename
  pathname.basename.to_s
end

#dirnameObject



30
31
32
# File 'lib/roast/value_objects/workflow_path.rb', line 30

def dirname
  pathname.dirname.to_s
end

#exist?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/roast/value_objects/workflow_path.rb', line 18

def exist?
  pathname.exist?
end

#hashObject



53
54
55
# File 'lib/roast/value_objects/workflow_path.rb', line 53

def hash
  [self.class, @value].hash
end

#relative?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/roast/value_objects/workflow_path.rb', line 26

def relative?
  pathname.relative?
end

#to_pathObject



42
43
44
# File 'lib/roast/value_objects/workflow_path.rb', line 42

def to_path
  @value
end

#to_sObject



38
39
40
# File 'lib/roast/value_objects/workflow_path.rb', line 38

def to_s
  @value
end