Class: Alda::Cram

Inherits:
Event
  • Object
show all
Includes:
EventList
Defined in:
lib/alda-rb/event.rb

Overview

A CRAM event. Includes Alda::EventList.

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

The duration of a cram event can be specified just like that of an Alda::Note.

Alda::Score.new do
  piano_ c3 t4 { c2 d4 e f }; g2
end

Instance Attribute Summary collapse

Attributes included from EventList

#events, #variables

Attributes inherited from Event

#container, #parent

Instance Method Summary collapse

Methods included from EventList

#events_alda_codes, #has_variable?, #import, #method_missing, #on_contained, #to_a

Methods inherited from Event

#detach_from_parent, #is_event_of?, #on_contained

Constructor Details

#initialize(duration, &block) ⇒ Cram

There is an event list sugar invoking this method, see Alda::EventList#method_missing.

block is to be passed with the CRAM object as self.

Alda::Score.new { piano_; t8 { a; b }}


974
975
976
977
# File 'lib/alda-rb/event.rb', line 974

def initialize duration, &block
	@duration = duration
	super &block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Alda::EventList

Instance Attribute Details

#durationObject

The string representing the duration of the CRAM.



965
966
967
# File 'lib/alda-rb/event.rb', line 965

def duration
  @duration
end

Instance Method Details

#==(other) ⇒ Object

:call-seq:

cram == other -> true or false

Overrides Alda::EventList#==. Returns true if the super method returns true and other has the same #duration as cram (using ==).



995
996
997
# File 'lib/alda-rb/event.rb', line 995

def == other
	super && @duration == other.duration
end

#to_alda_codeObject

:call-seq:

to_alda_code() -> String

Overrides Alda::Event#to_alda_code.



984
985
986
# File 'lib/alda-rb/event.rb', line 984

def to_alda_code
	"{#{events_alda_codes}}#@duration"
end