Class: AnyStyle::Feature::Ref
- Inherits:
-
AnyStyle::Feature
- Object
- AnyStyle::Feature
- AnyStyle::Feature::Ref
- Defined in:
- lib/anystyle/feature/ref.rb
Instance Attribute Summary
Attributes inherited from AnyStyle::Feature
Instance Method Summary collapse
Methods inherited from AnyStyle::Feature
#initialize, #next, #prev, #ratio
Methods included from StringUtils
canonize, count, display_chars, display_width, indent, page_break?, scrub, 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 |
# File 'lib/anystyle/feature/ref.rb', line 4 def observe(token, **opts) [ symbolize(count(token, /\b(1\d|20)\d\d\b/)), symbolize(count(token, /(\d[\(:;]\d)|(\d\s*\p{Pd}+\s*\d)|\bpp?\.|\bvols?\.|\bnos?\./i)), symbolize(count(token, /\b\p{Lu}\./)), symbolize(count(token, /\b(eds?\.|edited by|editors?|hg|hrsg|et al)\b/i)), token =~ /^\s*(\[\w+\]|\(\d+\)|\d+\.)\s+/ ? 'T' : 'F' ] end |
#symbolize(k) ⇒ Object
14 15 16 17 18 |
# File 'lib/anystyle/feature/ref.rb', line 14 def symbolize(k) return '-' if k < 1 return '+' if k < 3 return '++' end |