Class: Picky::Generators::Partial::Infix
- Defined in:
- lib/picky/generators/partial/infix.rb
Overview
The subtoken partial strategy.
If given “florian” it will index “floria”, “flori”, “flor”, “flo”, “fl”, “f” (Depending on what the given from value is, the example is with option from: 1)
Instance Attribute Summary collapse
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
Instance Method Summary collapse
-
#each_partial(token, &block) ⇒ Object
Yields each generated partial.
-
#initialize(options = {}) ⇒ Infix
constructor
The min option signifies with what size it will start in generating the infix tokens.
Methods inherited from Strategy
Constructor Details
#initialize(options = {}) ⇒ Infix
The min option signifies with what size it will start in generating the infix tokens.
Examples:
With :hello, and max: -1 (default)
-
min: 1 # => [:hello, :hell, :ello, :hel, :ell, :llo, :he, :el, :ll, :lo, :h, :e, :l, :l, :o]
-
min: 4 # => [:hello, :hell, :ello]
With :hello, and max: -2
-
min: 1 # => [:hell, :ello, :hel, :ell, :llo, :he, :el, :ll, :lo, :h, :e, :l, :l, :o]
-
min: 4 # => [:hell, :ello]
(min 1 is default)
33 34 35 36 |
# File 'lib/picky/generators/partial/infix.rb', line 33 def initialize = {} @min = [:min] || 1 @max = [:max] || -1 end |
Instance Attribute Details
#max ⇒ Object (readonly)
Returns the value of attribute max.
15 16 17 |
# File 'lib/picky/generators/partial/infix.rb', line 15 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
15 16 17 |
# File 'lib/picky/generators/partial/infix.rb', line 15 def min @min end |
Instance Method Details
#each_partial(token, &block) ⇒ Object
Yields each generated partial.
40 41 42 |
# File 'lib/picky/generators/partial/infix.rb', line 40 def each_partial token, &block token.each_intoken min, max, &block end |