Class: Roast::ValueObjects::StepName

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

Overview

Value object representing a step name, which can be either a plain text prompt or a reference to a step file

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ StepName

Returns a new instance of StepName.



10
11
12
13
# File 'lib/roast/value_objects/step_name.rb', line 10

def initialize(name)
  @value = name.to_s.strip
  freeze
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/roast/value_objects/step_name.rb', line 8

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/roast/value_objects/step_name.rb', line 30

def ==(other)
  case other
  when StepName
    value == other.value
  when String
    value == other
  else
    false
  end
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/roast/value_objects/step_name.rb', line 41

def eql?(other)
  other.is_a?(StepName) && value == other.value
end

#file_reference?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/roast/value_objects/step_name.rb', line 19

def file_reference?
  !plain_text?
end

#hashObject



45
46
47
# File 'lib/roast/value_objects/step_name.rb', line 45

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

#plain_text?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/roast/value_objects/step_name.rb', line 15

def plain_text?
  @value.include?(" ")
end

#to_sObject Also known as: to_str



23
24
25
# File 'lib/roast/value_objects/step_name.rb', line 23

def to_s
  @value
end