class Alda::Rest

A rest event. An Alda::EventContainer containing an Alda::Rest can be created using event list sugar. See Alda::EventList#method_missing.

When using event list sugar, its duration can be specified just like that of Alda::Note.

Alda::Score.new do
  piano_ c8 r4 c8 r4 c4
end

Attributes

duration[RW]

The string representing a duration.

Public Class Methods

new(duration) → Alda::Rest click to toggle source

Creates an Alda::Rest.

Underlines “_” in duration will be converted to tildes “~”.

Calls superclass method
# File lib/alda-rb/event.rb, line 617
def initialize duration
  super()
  @duration = duration.to_s.tr ?_, ?~
end

Public Instance Methods

rest == other → true or false click to toggle source

Overrides Alda::Event#==. Returns true if other is an Alda::Rest and has the same duration as rest (using ==).

Calls superclass method Alda::Event#==
# File lib/alda-rb/event.rb, line 638
def == other
  super || other.is_a?(Alda::Rest) && @duration == other.duration
end
to_alda_code() → String click to toggle source

Overrides Alda::Event#to_alda_code.

# File lib/alda-rb/event.rb, line 627
def to_alda_code
  ?r + @duration
end