Class: Picky::Generators::Partial::Substring
- Defined in:
- lib/picky/generators/partial/substring.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)
Direct Known Subclasses
Instance Method Summary collapse
-
#each_partial(token, &block) ⇒ Object
Yields each generated partial.
-
#from ⇒ Object
Delegator to generator#from.
-
#initialize(options = {}) ⇒ Substring
constructor
The from option signifies where in the symbol it will start in generating the subtokens.
-
#to ⇒ Object
Delegator to generator#to.
Methods inherited from Strategy
Methods inherited from Strategy
Constructor Details
#initialize(options = {}) ⇒ Substring
The from option signifies where in the symbol it will start in generating the subtokens.
Examples:
With :hello, and to: -1 (default)
-
from: 1 # => [:hello, :hell, :hel, :he, :h]
-
from: 4 # => [:hello, :hell]
With :hello, and to: -2
-
from: 1 # => [:hell, :hel, :he, :h]
-
from: 4 # => [:hell]
57 58 59 60 61 |
# File 'lib/picky/generators/partial/substring.rb', line 57 def initialize = {} from = [:from] || 1 to = [:to] || -1 @generator = SubstringGenerator.new from, to end |
Instance Method Details
#each_partial(token, &block) ⇒ Object
Yields each generated partial.
77 78 79 |
# File 'lib/picky/generators/partial/substring.rb', line 77 def each_partial token, &block @generator.each_subtoken token, &block end |
#from ⇒ Object
Delegator to generator#from.
65 66 67 |
# File 'lib/picky/generators/partial/substring.rb', line 65 def from @generator.from end |
#to ⇒ Object
Delegator to generator#to.
71 72 73 |
# File 'lib/picky/generators/partial/substring.rb', line 71 def to @generator.to end |