lib/music/interval.rb
def size
      result = 0
      current_number = number

      while current_number >= OCTAVE
        result += SIZES[OCTAVE][0]
        current_number -= OCTAVE - 1
      end

      sizes = SIZES.fetch(current_number)
      result +=
        case quality
        when :diminished then sizes.first - 1
        when :minor      then sizes.first
        when :perfect    then sizes[0]
        when :major      then sizes.last
        when :augmented  then sizes.last  + 1
        end

      result * direction
    end
##
# Returns the number of semitones that interval covers.
#
# @return [Integer]
#
Returns the number of semitones that interval covers.
Returns the number of semitones that interval covers .
def size
      result = 0
      current_number = number
      while current_number >= OCTAVE
        result += SIZES[OCTAVE][0]
        current_number -= OCTAVE - 1
      end
      sizes = SIZES.fetch(current_number)
      result +=
        case quality
        when :diminished then sizes.first - 1
        when :minor      then sizes.first
        when :perfect    then sizes[0]
        when :major      then sizes.last
        when :augmented  then sizes.last  + 1
        end
      result * direction
    end
def size result = 0 current_number = number while current_number >= OCTAVE result += SIZES [ OCTAVE ] [ 0 ] current_number -= OCTAVE - 1 end sizes = SIZES . fetch ( current_number ) result += case quality when :diminished then sizes . first - 1 when :minor then sizes . first when :perfect then sizes [ 0 ] when :major then sizes . last when :augmented then sizes . last + 1 end result * direction end
Returns the number of semitones that interval covers.
Returns the number of semitones that interval covers .
None
Integer