class Alda::OrderError

This error is raised when one tries to append events in an Alda::EventList in a wrong order.

Alda::Score.new do
  motif = f4 f e e d d c2
  g4 f e d c2 # It commented out, error will not occur
  c4 c g g a a g2 motif # (OrderError)
end

Attributes

expected[R]

The expected element gotten if it is of the correct order. See got.

Alda::Score.new do
  motif = f4 f e e d d c2
  g4 f e d c2
  p @events.size # => 2
  c4 c g g a a g2 motif
rescue OrderError => e
  p @events.size # => 1
  p e.expected   # => #<Alda::EventContainer:...>
  p e.got        # => #<Alda::EventContainer:...>
end
got[R]

The actually gotten element. For an example, see expected.

Public Class Methods

new(expected, got) → Alda::OrderError click to toggle source

Creates a Alda::OrderError object.

Calls superclass method
# File lib/alda-rb/error.rb, line 159
def initialize expected, got
  super 'events are out of order'
  @expected = expected
  @got = got
end