Class: AnyStyle::Feature::Indent

Inherits:
AnyStyle::Feature show all
Defined in:
lib/anystyle/feature/indent.rb

Instance Attribute Summary

Attributes inherited from AnyStyle::Feature

#precision

Instance Method Summary collapse

Methods inherited from AnyStyle::Feature

#initialize, #next, #prev, #ratio

Methods included from StringUtils

canonize, count, display_chars, display_width, indent, nnum, page_break?, scrub, strip_html, transliterate

Constructor Details

This class inherits a constructor from AnyStyle::Feature

Instance Method Details

#observe(token, seq:, idx:, **opts) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/anystyle/feature/indent.rb', line 4

def observe(token, seq:, idx:, **opts)
  i = indent(token)
  p = prev(idx, seq)
  j = p.nil? ? 0 : indent(p.value)

  [
    (i > 0) ? 'T' : 'F',
    (i < j) ? '-' : (i > j) ? '+' : '=',
  ]
end