Class: Roast::ValueObjects::StepName
- Inherits:
-
Object
- Object
- Roast::ValueObjects::StepName
- 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
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #file_reference? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name) ⇒ StepName
constructor
A new instance of StepName.
- #plain_text? ⇒ Boolean
- #to_s ⇒ Object (also: #to_str)
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
#value ⇒ Object (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
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
19 20 21 |
# File 'lib/roast/value_objects/step_name.rb', line 19 def file_reference? !plain_text? end |
#hash ⇒ Object
45 46 47 |
# File 'lib/roast/value_objects/step_name.rb', line 45 def hash [self.class, @value].hash end |
#plain_text? ⇒ Boolean
15 16 17 |
# File 'lib/roast/value_objects/step_name.rb', line 15 def plain_text? @value.include?(" ") end |
#to_s ⇒ Object Also known as: to_str
23 24 25 |
# File 'lib/roast/value_objects/step_name.rb', line 23 def to_s @value end |