class AnyStyle::Feature

Attributes

precision[R]

Public Class Methods

new(precision: 10, **opts) click to toggle source
  # File lib/anystyle/feature.rb
7 def initialize(precision: 10, **opts)
8   @precision = precision
9 end

Public Instance Methods

next(idx, seq) click to toggle source
   # File lib/anystyle/feature.rb
15 def next(idx, seq)
16   sequence[idx + 1]
17 end
observe(token, **opts) click to toggle source
   # File lib/anystyle/feature.rb
11 def observe(token, **opts)
12   raise NotImplementedError
13 end
prev(idx, seq) click to toggle source
   # File lib/anystyle/feature.rb
19 def prev(idx, seq)
20   idx == 0 ? nil : seq[idx - 1]
21 end
ratio(x, y) click to toggle source
   # File lib/anystyle/feature.rb
23 def ratio(x, y)
24   (y > 0) ? ((x.to_f / y) * precision).round : 0
25 end