Class: IncomeTax::Register

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/income_tax/register.rb

Instance Method Summary collapse

Constructor Details

#initialize(type = "entry") ⇒ Register

Returns a new instance of Register.



5
6
7
8
# File 'lib/income_tax/register.rb', line 5

def initialize(type = "entry")
  @type     = type
  @register = {}
end

Instance Method Details

#add(key, value) ⇒ Object Also known as: []=



10
11
12
# File 'lib/income_tax/register.rb', line 10

def add(key, value)
  @register[normalize(key)] = value
end

#each(&block) ⇒ Object



20
21
22
# File 'lib/income_tax/register.rb', line 20

def each(&block)
  @register.values.uniq(&block)
end

#get(key) ⇒ Object Also known as: []



14
15
16
17
18
# File 'lib/income_tax/register.rb', line 14

def get(key)
  @register.fetch(normalize(key)) do
    raise ArgumentError, "unknown #{@type} #{key.inspect}"
  end
end

#include?(key) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/income_tax/register.rb', line 24

def include?(key)
  @register.include? normalize(key)
end