Class: SubType::RotationType

Inherits:
Object
  • Object
show all
Defined in:
lib/subtype.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#postObject

Returns the value of attribute post.



38
39
40
# File 'lib/subtype.rb', line 38

def post
  @post
end

#preObject

Returns the value of attribute pre.



38
39
40
# File 'lib/subtype.rb', line 38

def pre
  @pre
end

Instance Method Details

#nextObject



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