Last active
January 25, 2016 00:50
-
-
Save darinthompson/40d9b8ce770816c8de6a to your computer and use it in GitHub Desktop.
Calculates amount of money made between two dates.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
class PerDiem | |
PERDIEM = 93.00 | |
attr_accessor :start_date, :end_date, | |
def initalize(start_date, end_date) | |
@start_date = start_date | |
@end_date = end_date | |
end | |
def get_dates | |
puts "Insert dates. (dd/mm/yyyy)" | |
puts "starting date..." | |
start_date = Date.parse(gets.chomp) | |
puts "ending date..." | |
end_date = Date.parse(gets.chomp) | |
end | |
def number_of_days | |
number_of_days = (end_date - start_date).to_i | |
end | |
def calculate_per_diem | |
PERDIEM * number_of_days | |
end | |
end | |
darin = PerDiem.new | |
darin.get_dates | |
puts darin.number_of_days |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment