Class: Stave::Theory::Degree

Inherits:
Core::Lookup show all
Defined in:
lib/stave/theory/degree.rb

Instance Attribute Summary

Attributes inherited from Core::Lookup

#variant

Instance Method Summary collapse

Methods inherited from Core::Lookup

#==, each_key, find_by, #initialize, keys, string_keys, variant, variant?, variant_lookup, variants, where, with_options

Constructor Details

This class inherits a constructor from Stave::Core::Lookup

Instance Method Details

#+(other) ⇒ Object



104
105
106
107
108
# File 'lib/stave/theory/degree.rb', line 104

def +(other)
  new_interval = interval + other.interval

  Degree.find_by(interval: new_interval)
end

#-(other) ⇒ Object



110
111
112
113
114
# File 'lib/stave/theory/degree.rb', line 110

def -(other)
  new_interval = interval - other.interval

  Degree.find_by(interval: new_interval)
end

#symbolObject



94
95
96
97
98
# File 'lib/stave/theory/degree.rb', line 94

def symbol
  return "R" if (to_i % 12).zero?

  "#{accidental.symbol}#{interval.number.symbol}"
end

#to_iObject



100
101
102
# File 'lib/stave/theory/degree.rb', line 100

def to_i
  interval.to_i
end