Class: Yalphabetize::OrderCheckers::Custom

Inherits:
Base
  • Object
show all
Defined in:
lib/yalphabetize/order_checkers/custom.rb

Instance Method Summary collapse

Methods inherited from Base

new_for, #ordered?

Constructor Details

#initialize(allowed_order) ⇒ Custom

Returns a new instance of Custom.



6
7
8
9
# File 'lib/yalphabetize/order_checkers/custom.rb', line 6

def initialize(allowed_order)
  super()
  @allowed_order = allowed_order
end

Instance Method Details

#compare(string, other_string) ⇒ Object



11
12
13
# File 'lib/yalphabetize/order_checkers/custom.rb', line 11

def compare(string, other_string)
  allowed_order.index(string) <=> allowed_order.index(other_string)
end