Class: Contador

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#splitterObject

Returns the value of attribute splitter.



13
14
15
# File 'lib/contador.rb', line 13

def splitter
  @splitter
end

#stringObject

Returns the value of attribute string.



13
14
15
# File 'lib/contador.rb', line 13

def string
  @string
end

Instance Method Details

#delete_omitsObject



24
25
26
27
28
# File 'lib/contador.rb', line 24

def delete_omits
  $omits.split(' ').each do |word|
    @final.delete(word)
  end
end

#multiplicityObject



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