Class: Alda::Marker

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

Overview

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

It should be used together with Alda::AtMarker.

Alda::Score.new do
  piano_ v1 c d _here e2 v2 __here c4 d e2
end

Instance Attribute Summary collapse

Attributes inherited from Event

#container, #parent

Instance Method Summary collapse

Methods inherited from Event

#detach_from_parent, #is_event_of?, #on_contained

Constructor Details

#initialize(name) ⇒ Marker

:call-seq:

new(name) -> Alda::Marker

Creates an Alda::Marker.

Underlines in name is converted to hyphens.



1023
1024
1025
1026
# File 'lib/alda-rb/event.rb', line 1023

def initialize name
	super()
	@name = Alda::Utils.snake_to_slug name
end

Instance Attribute Details

#nameObject

The marker’s name



1014
1015
1016
# File 'lib/alda-rb/event.rb', line 1014

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object

:call-seq:

marker == other -> true or false

Overrides Alda::Event#==. Returns true if other is an Alda::Marker and has the same #name as marker (using ==).



1044
1045
1046
# File 'lib/alda-rb/event.rb', line 1044

def == other
	super || other.is_a?(Alda::Marker) && @name == other.name
end

#to_alda_codeObject

:call-seq:

to_alda_code() -> String

Overrides Alda::Event#to_alda_code.



1033
1034
1035
# File 'lib/alda-rb/event.rb', line 1033

def to_alda_code
	?% + @name
end