travis-ci
150 of 150 new or added lines in 14 files covered. (100.0%)
542 of 727 relevant lines covered (74.55%)
49056.14 hits per line
|
module Anystyle |
1✔ |
|
class Feature |
1✔ |
|
class Affix < Feature |
1✔ |
|
attr_reader :size
|
1✔ |
5 |
|
|
|
def initialize(size: 4, prefix: true, suffix: false) |
1✔ |
|
@size, @suffix = size, (suffix || !prefix) |
60✔ |
8 |
end
|
|
9 |
|
|
|
def elicit(token, *args) |
1✔ |
|
build(extract(token)) { |chars| join(chars) } |
12,190✔ |
12 |
end
|
|
13 |
|
|
|
def extract(token) |
1✔ |
|
if suffix?
|
2,438✔ |
|
token.chars.reverse.take(size) |
1,219✔ |
17 |
else
|
|
|
token.chars.take(size) |
1,219✔ |
19 |
end
|
|
20 |
end
|
|
21 |
|
|
|
def join(chars) |
1✔ |
|
if suffix?
|
9,752✔ |
|
chars.reverse.join('')
|
4,876✔ |
25 |
else
|
|
|
chars.join('')
|
4,876✔ |
27 |
end
|
|
28 |
end
|
|
29 |
|
|
|
def build(chars) |
1✔ |
|
(1..size).map { |n| yield chars.take(n) } |
12,190✔ |
32 |
end
|
|
33 |
|
|
|
def suffix? |
1✔ |
|
!!@suffix
|
12,190✔ |
36 |
end
|
|
37 |
|
|
|
def prefix? |
1✔ |
|
!suffix? |
× |
40 |
end
|
|
41 |
end
|
|
42 |
end
|
|
43 |
end
|