-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Carets -- Guillermina Muro #40
base: master
Are you sure you want to change the base?
Conversation
…ck in date is equal to a reservation's checkout date
…r for reserving a block to be raised if available rooms are less than the num of rooms called
…put id so it is more descriptive
… id so it is more descriptive
I love this approach! The hotel as a module works great. I'm really happy with your work on the optionals of reading from a CSV-- and it was very close to working with writing to the CSV too! ;) Your hotel is certainly doing a lot... which makes sense, because every other class is structured to represent some data, while hotel holds it all together.
and I could see some areas of being able to pull out the CSV parsing action. Also, there are just some danger areas where your hotel does a lot of work that can be delegated to the other classes. I've made a few comments in some areas. Overall good work though |
return all_blocks | ||
end | ||
|
||
def self.cost(input_reservation_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should reuse self.find_reservation
here!
HotelWhat We're Looking For
|
by the way, I love the process of working through this project that you described in your comprehension questions ;) |
lib/hotel.rb
Outdated
unavailable_rooms = [] | ||
all_reservations = self.all_reservations | ||
all_reservations.each do |reservation| | ||
if (begin_search >= reservation.check_in) && (begin_search < reservation.check_out) && (end_search >= reservation.check_in) && (end_search <= reservation.check_out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this logic can be returned from a reservation itself if you pass in the begin_search and end_search properties instead! That way, hotel doesn't need to know that a reservation has a .check_in
and a .check_out
lib/hotel.rb
Outdated
blocked_rooms = [] | ||
all_the_blocks = self.all_blocks | ||
all_the_blocks.each do |block| | ||
if (begin_search >= block.check_in) && (begin_search < block.check_out) && (end_search >= block.check_in) && (end_search <= block.check_out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as the other comment
block = self.find_block(block_id) | ||
raise ArgumentError.new "Block ID is not found" if !(block.is_a? Hotel::Block) | ||
# block.add_rooms | ||
availability = block_available(block_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this method, you've already found the block object and stored it in block
, but then you redo that work in calling block_available
and passing in the block_id instead of the block itself.
I would refactor this so that it relies on block more, and lets block return internal information about itself
array_check_out =[block.check_out.year, block.check_out.month, block.check_out.day] | ||
new_reservation = Hotel::Reservation.new(5, block.rooms[0].id, array_check_in, array_check_out, block.block_id) | ||
# block.add_reservations # => does nothing currently, would work if I was writing new reservations to CSV...)-':' | ||
block.reservations << (new_reservation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally instead of shoveling into a block's internal property reservations
, you would use a method
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions