Class: RothIRA

Inherits:
Object
  • Object
show all
Defined in:
lib/roth_ira.rb,
lib/roth_ira/version.rb

Constant Summary collapse

VERSION =
'1.2.1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(year) ⇒ RothIRA

Returns a new instance of RothIRA.

Raises:

  • (ArgumentError)


6
7
8
9
10
# File 'lib/roth_ira.rb', line 6

def initialize(year)
  raise(ArgumentError, "Invalid Tax Year #{year}") unless year.between?(2015, 2018)
  @year = year
  @limits = YAML.load(File.read(__dir__ + "/limits.yaml"))[year]
end

Instance Attribute Details

#ageObject (readonly)

Returns the value of attribute age.



4
5
6
# File 'lib/roth_ira.rb', line 4

def age
  @age
end

#agiObject (readonly)

Returns the value of attribute agi.



4
5
6
# File 'lib/roth_ira.rb', line 4

def agi
  @agi
end

#filing_statusObject (readonly)

Returns the value of attribute filing_status.



4
5
6
# File 'lib/roth_ira.rb', line 4

def filing_status
  @filing_status
end

#limitsObject (readonly)

Returns the value of attribute limits.



4
5
6
# File 'lib/roth_ira.rb', line 4

def limits
  @limits
end

#spouse_ageObject (readonly)

Returns the value of attribute spouse_age.



4
5
6
# File 'lib/roth_ira.rb', line 4

def spouse_age
  @spouse_age
end

#yearObject (readonly)

Returns the value of attribute year.



4
5
6
# File 'lib/roth_ira.rb', line 4

def year
  @year
end

Instance Method Details

#calculate(agi, filing_status, *ages) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/roth_ira.rb', line 12

def calculate(agi, filing_status, *ages)
  @agi = agi
  @filing_status = filing_status
  @age = ages.first
  @spouse_age = ages.size == 2 ? ages.last : 0

  calculate_limit
end