Class: AnyStyle::Feature::Brackets

Inherits:
AnyStyle::Feature show all
Defined in:
lib/anystyle/feature/brackets.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, **opts) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/anystyle/feature/brackets.rb', line 4

def observe(token, **opts)
  case token
  when /^[^\(\[<>\)\]]+$/
    :none
  when /^\(.*\)[,;:\p{Pd}\.]?$/
    :parens
  when /^\[.*\][,;:\p{Pd}\.]?$/
    :'square-brackets'
  when /^<.*>[,;:\p{Pd}\.]?$/
    :angle
  when /\)[,;:\p{Pd}\.]?$/
    :'closing-paren'
  when /^\(/
    :'opening-paren'
  when /\][,;:\p{Pd}\.]?$/
    :'closing-square-bracket'
  when /^\[/
    :'opening-square-bracket'
  when />[,;:\p{Pd}\.]?$/
    :'closing-angle'
  when /^</
    :'opening-angle'
  else
    :other
  end
end