Class: Contador
- Inherits:
-
Object
- Object
- Contador
- Defined in:
- lib/contador.rb
Instance Attribute Summary collapse
-
#splitter ⇒ Object
Returns the value of attribute splitter.
-
#string ⇒ Object
Returns the value of attribute string.
Instance Method Summary collapse
- #delete_omits ⇒ Object
-
#initialize(string, splitter = SimpleSplitter) ⇒ Contador
constructor
A new instance of Contador.
- #multiplicity ⇒ Object
- #omit(word) ⇒ Object
Constructor Details
#initialize(string, splitter = SimpleSplitter) ⇒ Contador
Returns a new instance of Contador.
15 16 17 18 19 20 21 22 |
# File 'lib/contador.rb', line 15 def initialize(string, splitter=SimpleSplitter) @omit = [] @string = string @final = Hash.new @splitter = splitter split_string_into_hash delete_omits if $omits end |
Instance Attribute Details
#splitter ⇒ Object
Returns the value of attribute splitter.
13 14 15 |
# File 'lib/contador.rb', line 13 def splitter @splitter end |
#string ⇒ Object
Returns the value of attribute string.
13 14 15 |
# File 'lib/contador.rb', line 13 def string @string end |
Instance Method Details
#delete_omits ⇒ Object
24 25 26 27 28 |
# File 'lib/contador.rb', line 24 def delete_omits $omits.split(' ').each do |word| @final.delete(word) end end |
#multiplicity ⇒ Object
30 31 32 |
# File 'lib/contador.rb', line 30 def multiplicity @final end |
#omit(word) ⇒ Object
34 35 36 |
# File 'lib/contador.rb', line 34 def omit(word) @final.delete(word) end |