Method: MTK::Groups::Melody#=~

Defined in:
lib/mtk/groups/melody.rb

#=~(other) ⇒ Object

Compare for equality, ignoring order and duplicates

Parameters:



71
72
73
74
75
76
77
78
79
# File 'lib/mtk/groups/melody.rb', line 71

def =~ other
  @normalized_pitches ||= @pitches.uniq.sort
  @normalized_pitches == case
    when other.respond_to?(:pitches) then other.pitches.uniq.sort
    when (other.is_a? Array and other.frozen?) then other
    when other.respond_to?(:to_a) then other.to_a.uniq.sort
    else other
  end
end