Module: JishoSort::Comparable

Included in:
String
Defined in:
lib/jisho_sort/comparable.rb

Instance Method Summary collapse

Instance Method Details

#compare_by_furigana(other) ⇒ Integer

Compares the current string include chines and japanese character with another string based on their japanese pronunciation(furigana).

Parameters:

  • other (String)

    The object to compare with.

Returns:

  • (Integer)

    Returns -1 if the current object’s furigana is less than the other’s, 0 if they are equal, and 1 if it is greater.

Raises:

  • (ArgumentError)


7
8
9
10
11
# File 'lib/jisho_sort/comparable.rb', line 7

def compare_by_furigana(other)
  raise ArgumentError unless other.instance_of?(String)

  furigana <=> other.furigana
end