Module: Chords::Note
- Includes:
- Comparable
- Defined in:
- lib/chords/note.rb
Instance Attribute Summary collapse
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#octave ⇒ Object
readonly
Returns the value of attribute octave.
Class Method Summary collapse
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #<=>(other) ⇒ Object
- #coerce(other) ⇒ Object
- #title ⇒ Object
- #value ⇒ Object
Instance Attribute Details
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
8 9 10 |
# File 'lib/chords/note.rb', line 8 def interval @interval end |
#octave ⇒ Object (readonly)
Returns the value of attribute octave.
8 9 10 |
# File 'lib/chords/note.rb', line 8 def octave @octave end |
Class Method Details
Instance Method Details
#+(other) ⇒ Object
38 |
# File 'lib/chords/note.rb', line 38 def +(other); Note.create_by_value(value + other) end |
#-(other) ⇒ Object
39 |
# File 'lib/chords/note.rb', line 39 def -(other); Note.create_by_value(value - other) end |
#<=>(other) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/chords/note.rb', line 20 def <=>(other) if other.respond_to?(:value) value <=> other.value else value <=> other end end |
#coerce(other) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/chords/note.rb', line 28 def coerce(other) if other.respond_to?(:value) [other.value, value] else [other, value] end end |
#title ⇒ Object
36 |
# File 'lib/chords/note.rb', line 36 def title; self.class.title end |
#value ⇒ Object
16 17 18 |
# File 'lib/chords/note.rb', line 16 def value (@octave * 12) + @interval end |