diff --git a/Guardfile b/Guardfile index 6760f9177..a4b447f94 100644 --- a/Guardfile +++ b/Guardfile @@ -1,5 +1,5 @@ -guard :minitest, bundler: false, rubygems: false do - # with Minitest::Spec +guard :minitest, bundler: false, autorun: false, rubygems: false do + # With Minitest Reporters watch(%r{^spec/(.*)_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^spec/spec_helper\.rb$}) { 'spec' } diff --git a/lib/reservation.rb b/lib/reservation.rb new file mode 100644 index 000000000..dda6b21ce --- /dev/null +++ b/lib/reservation.rb @@ -0,0 +1,41 @@ +# #Reservation +# A ticket stub with reservation details +#check-in, check-out +#As an administrator, I can reserve a room for a given date range +require 'pry' +require 'date' +require 'awesome_print' +require_relative 'room' + +class Reservation + + attr_reader :start_date, :end_date, :room, :total_cost + + def initialize(start_date, end_date, room) + @start_date = start_date + @end_date = end_date + @room = room + @total_cost = calculate_total_cost + end + + def calculate_total_cost() + total_cost = 0 + number_of_days = ((end_date - start_date).to_i) - 1 + if number_of_days < 1 + number_of_days = 1 + end + total_cost = number_of_days * 200 + return total_cost + end + + + def date_overlap_check(start_date, end_date) + @bookings.each do |booking| + if start_date == booking.start_date && end_date == booking.end_date + end + return true + end + end + + +end diff --git a/lib/room.rb b/lib/room.rb new file mode 100644 index 000000000..8e405cfdd --- /dev/null +++ b/lib/room.rb @@ -0,0 +1,78 @@ +#Room Class +#The physical space also has nightly rate + +require 'pry' +require 'awesome_print' + +class Room + + attr_reader :id + + attr_accessor :cost + + def initialize(id, cost = 200 ) + @id = id + @cost = cost + end +end + + + +# class HotelMngr +# @room +# +# def book_room(start,end) +# @room.is_available(start:today) +# end +# end +# +# class Room +# def.is_available?(start: start_date, end: end_date) +# end +#new_room = Room.new(1, 200) +#ap new_room +#write method to list rooms +#ap self.all +#concerned with the physical space +# def self.all +# CSV.open('./data/customers.csv').map do |customer| +# id = customer[0].to_i +# email = customer[1] +# address = {street: customer[2], city: customer[3], state: customer[4], zip: customer[5]} +# +# Customer.new(id,email, address) +# end +# end +# end +# def room_id_assign +# rooms = [0...19] +# room_number = rooms.each_with_index do |index| +# room_number = room_numbers[i] +# room_number<