Module: Unnatural
- Defined in:
- lib/unnatural.rb,
lib/unnatural/fast.rb,
lib/unnatural/scan.rb,
lib/unnatural/split.rb,
lib/unnatural/version.rb,
lib/unnatural/substitution.rb
Overview
Defined Under Namespace
Modules: Fast, Scan, Split, Substitution
Constant Summary
collapse
- VERSION =
'0.3.2'.freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.algorithm ⇒ Object
11
12
13
|
# File 'lib/unnatural.rb', line 11
def self.algorithm
@algorithm
end
|
.algorithm=(mod) ⇒ Object
15
16
17
|
# File 'lib/unnatural.rb', line 15
def self.algorithm=(mod)
@algorithm = mod
end
|
.algorithms ⇒ Object
5
6
7
8
9
|
# File 'lib/unnatural.rb', line 5
def self.algorithms
[:Substitution, :Split, :Scan, :Fast]
.select { |name| const_defined?(name) }
.map { |name| const_get(name) }
end
|
.compare(a, b) ⇒ Object
28
29
30
|
# File 'lib/unnatural.rb', line 28
def self.compare(a, b)
@algorithm.compare(a, b)
end
|
.sort(enumerable) ⇒ Object
19
20
21
|
# File 'lib/unnatural.rb', line 19
def self.sort(enumerable)
@algorithm.sort(enumerable)
end
|
.sort_by(enumerable) ⇒ Object
23
24
25
26
|
# File 'lib/unnatural.rb', line 23
def self.sort_by(enumerable)
raise ArgumentError, 'Block expected but none given' unless block_given?
@algorithm.sort_by(enumerable) { |*a| yield(*a) }
end
|
Instance Method Details
#<=>(other) ⇒ Object
32
33
34
|
# File 'lib/unnatural.rb', line 32
def <=>(other)
Unnatural.compare(to_str, other.to_str)
end
|