Class: Yalphabetize::OrderCheckers::Base
- Inherits:
-
Object
- Object
- Yalphabetize::OrderCheckers::Base
show all
- Defined in:
- lib/yalphabetize/order_checkers/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.new_for(node) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/yalphabetize/order_checkers/base.rb', line 6
def self.new_for(node)
node_keys = node.children.select.each_with_index do |_, i|
i.even?
end.map(&:value)
matched_allowed_order = Yalphabetize.config['allowed_orders']&.find do |allowed_order|
(node_keys - allowed_order).empty?
end
matched_allowed_order ? Custom.new(matched_allowed_order) : new
end
|
Instance Method Details
#ordered?(string, other_string) ⇒ Boolean
18
19
20
|
# File 'lib/yalphabetize/order_checkers/base.rb', line 18
def ordered?(string, other_string)
!compare(string, other_string).positive?
end
|