Class: Niki::Part

Inherits:
Object
  • Object
show all
Includes:
Chords
Defined in:
lib/niki/part.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Chords

#silence

Constructor Details

#initialize(name, song, &block) ⇒ Part

Returns a new instance of Part.



7
8
9
10
11
12
# File 'lib/niki/part.rb', line 7

def initialize(name, song, &block)
  @name = name
  @song = song
  @notes = {}
  self.instance_eval(&block)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/niki/part.rb', line 3

def name
  @name
end

#notesObject (readonly)

Returns the value of attribute notes.



3
4
5
# File 'lib/niki/part.rb', line 3

def notes
  @notes
end

Instance Method Details

#for_instrument(instrument_name) ⇒ Object



14
15
16
# File 'lib/niki/part.rb', line 14

def for_instrument(instrument_name)
  @notes[instrument_name] || []
end

#riff(name, instrument_name, &blk) ⇒ Object



18
19
20
21
22
23
# File 'lib/niki/part.rb', line 18

def riff(name, instrument_name, &blk)
  riff = @song.get_riff(name)
  riff.notes.each do |args|
    send(instrument_name, *args)
  end
end