Class: SubType::RotationType
- Inherits:
-
Object
- Object
- SubType::RotationType
- Defined in:
- lib/subtype.rb
Instance Attribute Summary collapse
-
#post ⇒ Object
Returns the value of attribute post.
-
#pre ⇒ Object
Returns the value of attribute pre.
Instance Method Summary collapse
-
#initialize(phrase = '', max = 20, pre = '', post = '') ⇒ RotationType
constructor
A new instance of RotationType.
- #next ⇒ Object
- #update(phrase) ⇒ Object
Constructor Details
#initialize(phrase = '', max = 20, pre = '', post = '') ⇒ RotationType
Returns a new instance of RotationType.
39 40 41 42 43 44 |
# File 'lib/subtype.rb', line 39 def initialize(phrase = '', max = 20, pre = '', post = '') @max = max || 20 self.pre = pre || '' self.post = post || '' self.phrase = phrase end |
Instance Attribute Details
#post ⇒ Object
Returns the value of attribute post.
38 39 40 |
# File 'lib/subtype.rb', line 38 def post @post end |
#pre ⇒ Object
Returns the value of attribute pre.
38 39 40 |
# File 'lib/subtype.rb', line 38 def pre @pre end |
Instance Method Details
#next ⇒ Object
51 52 53 54 |
# File 'lib/subtype.rb', line 51 def next @rotation.rotate! if @phrase.size > @max @rotation.join[0, @max] end |
#update(phrase) ⇒ Object
46 47 48 49 |
# File 'lib/subtype.rb', line 46 def update(phrase) self.phrase = phrase unless phrase.is_a?(String) and @phrase.strip == phrase.strip end |