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
Defined Under Namespace
Modules: Fast, Scan, Split, Substitution
Constant Summary
collapse
- VERSION =
'0.3.0'.freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.algorithm ⇒ Object
10
11
12
|
# File 'lib/unnatural.rb', line 10
def self.algorithm
@algorithm
end
|
.algorithm=(mod) ⇒ Object
14
15
16
|
# File 'lib/unnatural.rb', line 14
def self.algorithm=(mod)
@algorithm = mod
end
|
.algorithms ⇒ Object
4
5
6
7
8
|
# File 'lib/unnatural.rb', line 4
def self.algorithms
[:Substitution, :Split, :Scan, :Fast]
.select { |name| const_defined?(name) }
.map { |name| const_get(name) }
end
|
.compare(a, b) ⇒ Object
27
28
29
|
# File 'lib/unnatural.rb', line 27
def self.compare(a, b)
@algorithm.compare(a, b)
end
|
.sort(enumerable) ⇒ Object
18
19
20
|
# File 'lib/unnatural.rb', line 18
def self.sort(enumerable)
@algorithm.sort(enumerable)
end
|
.sort_by(enumerable) ⇒ Object
22
23
24
25
|
# File 'lib/unnatural.rb', line 22
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
31
32
33
|
# File 'lib/unnatural.rb', line 31
def <=>(other)
Unnatural.compare(to_str, other.to_str)
end
|