Class: Alda::Voice

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

Overview

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

Alda::Score.new do
  piano_ v1 c d e f v2 e f g a
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(num) ⇒ Voice

:call-seq:

new(num) -> Alda::Voice

Creates an Alda::Voice.



920
921
922
923
# File 'lib/alda-rb/event.rb', line 920

def initialize num
	super()
	@num = num
end

Instance Attribute Details

#numObject

The string representing the voice’s number.



913
914
915
# File 'lib/alda-rb/event.rb', line 913

def num
  @num
end

Instance Method Details

#==(other) ⇒ Object

:call-seq:

voice == other -> true or false

Overrides Alda::Event#==. Returns true if other is an Alda::Voice and has the same #num as voice (using ==).



941
942
943
# File 'lib/alda-rb/event.rb', line 941

def == other
	super || other.is_a?(Alda::Voice) && @num == other.num
end

#to_alda_codeObject

:call-seq:

to_alda_code() -> String

Overrides Alda::Event#to_alda_code.



930
931
932
# File 'lib/alda-rb/event.rb', line 930

def to_alda_code
	?V + num + ?:
end