travis-ci
171 of 171 new or added lines in 16 files covered. (100.0%)
532 of 717 relevant lines covered (74.2%)
49691.46 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) |
61✔ |
8 |
end
|
|
9 |
|
|
|
def elicit(token, *args) |
1✔ |
|
build(extract(token)) { |chars| join(chars) } |
12,443✔ |
12 |
end
|
|
13 |
|
|
|
def extract(token) |
1✔ |
|
if suffix?
|
2,489✔ |
|
token.chars.reverse.take(size) |
1,244✔ |
17 |
else
|
|
|
token.chars.take(size) |
1,245✔ |
19 |
end
|
|
20 |
end
|
|
21 |
|
|
|
def join(chars) |
1✔ |
|
if suffix?
|
9,954✔ |
|
chars.reverse.join('')
|
4,976✔ |
25 |
else
|
|
|
chars.join('')
|
4,978✔ |
27 |
end
|
|
28 |
end
|
|
29 |
|
|
|
def build(chars) |
1✔ |
|
(1..size).map { |n| yield chars.take(n) } |
12,443✔ |
32 |
end
|
|
33 |
|
|
|
def suffix? |
1✔ |
|
!!@suffix
|
12,443✔ |
36 |
end
|
|
37 |
|
|
|
def prefix? |
1✔ |
|
!suffix? |
× |
40 |
end
|
|
41 |
end
|
|
42 |
end
|
|
43 |
end
|