Class: Drudge::Parsers::ParseResults::Seq

Inherits:
Struct
  • Object
show all
Includes:
ParseValue
Defined in:
lib/drudge/parsers/parse_results.rb

Overview

A sequence of succesful results

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ParseValue

zero

Methods included from FactoryMethods

#Empty, #Error, #Failure, #Seq, #Single, #Success

Instance Attribute Details

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



221
222
223
# File 'lib/drudge/parsers/parse_results.rb', line 221

def value
  @value
end

Instance Method Details

#+(other) ⇒ Object



232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/drudge/parsers/parse_results.rb', line 232

def +(other)
  case other

  when Empty
    self 

  when Single
    Seq(self.value + [other.value])

  when Seq
    Seq(self.value + other.value)
  end
end

#flat_map {|value| ... } ⇒ Object

Yields:



228
229
230
# File 'lib/drudge/parsers/parse_results.rb', line 228

def flat_map
  yield value
end

#mapObject



224
225
226
# File 'lib/drudge/parsers/parse_results.rb', line 224

def map
  self.class.new(yield value)
end

#to_aObject



246
247
248
# File 'lib/drudge/parsers/parse_results.rb', line 246

def to_a
  value
end