push
travis-ci
600 of 746 relevant lines covered (80.43%)
24118.47 hits per line
1 |
module AnyStyle |
1✔ |
2 |
class Feature |
1✔ |
3 |
class Position < Feature |
1✔ |
4 |
attr_reader :precision, :idx, :seq |
1✔ |
5 |
|
|
6 |
def initialize(precision: 100, idx: :idx, seq: :seq) |
1✔ |
7 |
@precision, @idx, @seq = precision, idx, seq |
15✔ |
8 |
end
|
|
9 |
|
|
10 |
def observe(token, **opts) |
1✔ |
11 |
i = opts[idx] |
1,561✔ |
12 |
n = opts[seq].size |
1,561✔ |
13 |
|
|
14 |
case
|
|
15 |
when i == 0 && i == n - 1 |
|
16 |
:only
|
4✔ |
17 |
when i == 0 |
|
18 |
:first
|
70✔ |
19 |
when i = n - 1 |
|
20 |
:last
|
1,487✔ |
21 |
else
|
|
22 |
((i.to_f / n) * precision).round |
× |
23 |
end
|
1,561✔ |
24 |
end
|
|
25 |
end
|
|
26 |
end
|
|
27 |
end
|