Class: Stupidedi::Reader::Success

Inherits:
Either::Success show all
Includes:
Result
Defined in:
lib/stupidedi/reader/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Result

#column, failure, #line, #offset, #position, success

Methods inherited from Either::Success

#defined?, #explain, #fetch, #flatmap, #inspect, #map, #or, #reject, #select, #tap

Methods inherited from Either

#defined?, #explain, failure, #fetch, #flatmap, #map, #or, #reject, #select, success

Constructor Details

#initialize(value, remainder) ⇒ Success

Returns a new instance of Success.


59
60
61
# File 'lib/stupidedi/reader/result.rb', line 59

def initialize(value, remainder)
  @value, @remainder = value, remainder
end

Instance Attribute Details

#remainder (readonly)

Returns the value of attribute remainder


57
58
59
# File 'lib/stupidedi/reader/result.rb', line 57

def remainder
  @remainder
end

Instance Method Details

#==(other) ⇒ Boolean

Returns:

  • (Boolean)

75
76
77
78
79
80
81
# File 'lib/stupidedi/reader/result.rb', line 75

def ==(other)
  if other.is_a?(self.class)
    @value == other.value and @remainder == other.remainder
  else
    @value == other
  end
end

#blank?Boolean

Override Enumerable#blank? since we're not really Enumerable

Returns:

  • (Boolean)

98
99
100
# File 'lib/stupidedi/reader/result.rb', line 98

def blank?
  false
end

#copy(changes = {}) ⇒ Success

Returns:


64
65
66
67
68
# File 'lib/stupidedi/reader/result.rb', line 64

def copy(changes = {})
  Success.new \
    changes.fetch(:value, @value),
    changes.fetch(:remainder, @remainder)
end

#fatal?Boolean

Returns:

  • (Boolean)

70
71
72
# File 'lib/stupidedi/reader/result.rb', line 70

def fatal?
  false
end

#pretty_print(q)

This method returns an undefined value.

:nocov:


85
86
87
88
89
90
91
92
93
94
# File 'lib/stupidedi/reader/result.rb', line 85

def pretty_print(q)
  q.text "Result.success"
  q.group(2, "(", ")") do
    q.breakable ""
    q.pp @value
    q.text ","
    q.breakable
    q.pp @remainder
  end
end