Skip to content

Instantly share code, notes, and snippets.

@darinthompson
Last active January 25, 2016 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darinthompson/40d9b8ce770816c8de6a to your computer and use it in GitHub Desktop.
Save darinthompson/40d9b8ce770816c8de6a to your computer and use it in GitHub Desktop.
Calculates amount of money made between two dates.
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