Class: Picky::Generators::Partial::SubstringGenerator
- Defined in:
- lib/picky/generators/partial/substring.rb
Overview
Generates the right substrings for use in the substring strategy.
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(from, to) ⇒ SubstringGenerator
constructor
A new instance of SubstringGenerator.
Constructor Details
#initialize(from, to) ⇒ SubstringGenerator
Returns a new instance of SubstringGenerator.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/picky/generators/partial/substring.rb', line 13 def initialize from, to @from, @to = from, to if @to.zero? def each_subtoken token, &block token.each_subtoken @from, &block end else if @from < 0 && @to < 0 def each_subtoken token, &block token.each_subtoken @from - @to - 1, (0..@to), &block end else def each_subtoken token, &block token.each_subtoken @from, (0..@to), &block end end end end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
11 12 13 |
# File 'lib/picky/generators/partial/substring.rb', line 11 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
11 12 13 |
# File 'lib/picky/generators/partial/substring.rb', line 11 def to @to end |