Class: BasicBudget

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

Overview

super class defining a Basic Budget class

Instance Method Summary collapse

Constructor Details

#initialize(amount) ⇒ BasicBudget



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

def initialize(amount)
  @amount = amount
end

Instance Method Details

#aggressive_savingsObject

getter method for savings type: aggressive 20% savings on amount



14
15
16
# File 'lib/budgetGenerator.rb', line 14

def aggressive_savings
  0.20
end

#amountObject

getter method for amount



9
10
11
# File 'lib/budgetGenerator.rb', line 9

def amount
  @amount
end

#budget_categoryObject

getter method for budget category array



29
30
31
# File 'lib/budgetGenerator.rb', line 29

def budget_category
  @budget_category = ["Home_Rent", "Utilities", "Food_Groceries", "Departmental", "Entertainment", "Car_Auto", "Insurance_Medical", "Misc"]
end

#budget_category_percentageObject

getter method for budget category percentage



34
35
36
# File 'lib/budgetGenerator.rb', line 34

def budget_category_percentage
  @budget_category_percentage = [0.30, 0.25, 0.15, 0.10, 0.04, 0.06, 0.07, 0.03]
end

#generate_budgetObject

generate budget method



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/budgetGenerator.rb', line 39

def generate_budget
  @h = Hash.new
  @budget_category = ["Home_Rent", "Utilities", "Food_Groceries", "Departmental", "Entertainment", "Car_Auto", "Insurance_Medical", "Misc"]
  @budget_category_percentage = [0.30, 0.25, 0.15, 0.10, 0.04, 0.06, 0.07, 0.03]

#loop through budget category item and calculate pecentage, then store in a hash

  @budget_category.each_with_index do |expense_item, expense_index|
    @percentage_for_budget_item = @budget_category_percentage[expense_index]
    @calculated_budget_for_item = @amount.to_f * @percentage_for_budget_item.to_f
    @h.store("#{expense_item}".to_s, @calculated_budget_for_item.to_f.round(2))
  end

  @h

end

#low_savingsObject

getter method for savings type: low 5% savings on amount



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

def low_savings
  0.05
end

#medium_savingsObject

getter method for savings type: medium 13% savings on amount



19
20
21
# File 'lib/budgetGenerator.rb', line 19

def medium_savings
  0.13
end