Class: Alda::Sequence
- Includes:
- EventList
- Defined in:
- lib/alda-rb/event.rb
Overview
A sequence event. Includes Alda::EventList.
An Alda::EventContainer containing an Alda::Sequence can be created using event list sugar. See Alda::EventList#method_missing.
Alda::Score.new do
p s{ c; d; e; f }.event.class # => Alda::Sequence
end
There is also a special sequence sugar.
Alda::Score.new do
p((c d e f).event.class) # => Alda::Sequence
end
The effects of the two examples above are technically the same although actually the generated list of events are slightly different.
Defined Under Namespace
Modules: RefineFlatten
Instance Attribute Summary
Attributes included from EventList
Attributes inherited from Event
Class Method Summary collapse
-
.join(*events) ⇒ Object
:call-seq: join(*events) -> Alda::Sequence.
Instance Method Summary collapse
-
#to_alda_code ⇒ Object
:call-seq: to_alda_code() -> String.
Methods included from EventList
#==, #events_alda_codes, #has_variable?, #import, #initialize, #method_missing, #on_contained, #to_a
Methods inherited from Event
#==, #detach_from_parent, #is_event_of?, #on_contained
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Alda::EventList
Class Method Details
.join(*events) ⇒ Object
:call-seq:
join(*events) -> Alda::Sequence
Creates an Alda::Sequence object by joining events
.
The Alda::EventContainer objects are extracted, and the Alda::Sequence objects are flattened.
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 |
# File 'lib/alda-rb/event.rb', line 1160 def self.join *events new do @events = events.map do |event| while event.is_a?(Alda::EventContainer) && event.count == 1 && event.labels.empty? event = event.event end event.is_a?(Alda::Sequence) ? event.events : event end.flatten end end |
Instance Method Details
#to_alda_code ⇒ Object
:call-seq:
to_alda_code() -> String
Overrides Alda::Event#to_alda_code.
1148 1149 1150 |
# File 'lib/alda-rb/event.rb', line 1148 def to_alda_code "[#{events_alda_codes}]" end |