Sha256: 4c50c2fee7941aee3cb0abf58253961fdf8c8c6f808bda4c4523b17f258efac1

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

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
  
  def to_s
    return @target_pitch
  end
  
  class Slur < Link
    def initialize target_pitch
      super(target_pitch)
    end
    
    def to_s
      return "=" + super()
    end
  end
  
  class Legato < Link
    def initialize target_pitch
      super(target_pitch)
    end  
  
    def to_s
      return "-" + super()
    end
  end
  
  class Glissando < Link
    def initialize target_pitch
      super(target_pitch)
    end
    
    def to_s
      return "~" + super()
    end
  end
  
  class Portamento < Link
    def initialize target_pitch
      super(target_pitch)
    end
    
    def to_s
      return "/" + super()
    end
  end
end

end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
music-transcription-0.4.3 lib/music-transcription/link.rb
music-transcription-0.4.2 lib/music-transcription/link.rb
music-transcription-0.4.1 lib/music-transcription/link.rb
music-transcription-0.4.0 lib/music-transcription/link.rb