Sha256: 3eb626679151c44bd6f68e247e9c887eb3339ee0216d9db4d17e6bc6ccfc6191
Contents?: true
Size: 905 Bytes
Versions: 10
Compression:
Stored size: 905 Bytes
Contents
class HeadMusic::Placement include Comparable attr_reader :voice, :position, :rhythmic_value, :pitch delegate :composition, to: :voice delegate :spelling, to: :pitch, allow_nil: true def initialize(voice, position, rhythmic_value, pitch = nil) ensure_attributes(voice, position, rhythmic_value, pitch) end def note? pitch end def rest? !note? end def next_position position + rhythmic_value end def <=>(other) self.position <=> other.position end private def ensure_attributes(voice, position, rhythmic_value, pitch) @voice = voice ensure_position(position) @rhythmic_value = rhythmic_value @pitch = HeadMusic::Pitch.get(pitch) end def ensure_position(position) if position.is_a?(HeadMusic::Position) @position = position else @position = HeadMusic::Position.new(composition, position) end end end
Version data entries
10 entries across 10 versions & 1 rubygems