Sha256: 4020482b3c95eac329e95c175c5b59e07a2d02823e69243f419a3eb899ac7569

Contents?: true

Size: 768 Bytes

Versions: 3

Compression:

Stored size: 768 Bytes

Contents

module Music
module Transcription

# Defines a relationship (tie, slur, legato, etc.) to a note with a certain pitch.
#
# @author James Tunnell
#
# @!attribute [rw] target_pitch
#   @return [Pitch] The pitch of the note which is being connected to.
#
class Link
  attr_accessor :target_pitch
  
  def initialize target_pitch
    @target_pitch = target_pitch
  end

  def ==(other)
    self.class == other.class && self.target_pitch == other.target_pitch
  end
  
  def clone
    self.class.new @target_pitch.clone
  end
  
  [ :Slur,
    :Legato,
    :Glissando,
    :Portamento,
  ].each do |name|
    klass = Class.new(Link) do
      def initialize target_pitch
        super(target_pitch)
      end
    end
    Link.const_set(name.to_sym, klass)
  end
end

end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
music-transcription-0.7.3 lib/music-transcription/link.rb
music-transcription-0.7.2 lib/music-transcription/link.rb
music-transcription-0.7.1 lib/music-transcription/link.rb