Sha256: cd1842075a3e017dc1f80c7a6415dd56d8e07ebc74750a590350d4c32f1a9ddc
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
class Hotel @@all=[] attr_accessor :hotel_name,:city,:hotel_rating,:hotel_describe,:hotel_booking #----------------------------------------------------------------- def initialize(hotel_name,city,hotel_rating,hotel_describe,hotel_booking) @hotel_name=hotel_name @hotel_rating=hotel_rating @hotel_describe=hotel_describe @hotel_booking=hotel_booking self.city=city city.hotels << self @@all << self end #----------------------------------------------------------------- def self.clear_all @@all.clear end def self.find(id) @@all[id] end def self.all @@all end #---------------------------- def self.hotel_info(id) hotel=self.find(id) puts "" puts "+-------------------------------------------------------------------------+".red puts " #{hotel.hotel_name}\t".blue + "#{hotel.hotel_rating}\t".yellow + "#{hotel.hotel_booking}".green puts " #{hotel.hotel_describe}" puts "+-------------------------------------------------------------------------+".red puts "" end #----------------------------------------------------------------- def self.find_by_city_name(city) @@all.select{|h| h.city.name == city || h.city.name == "Baghdād"}.map{|h| h.hotel_name} end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
iraq_hotels-0.1.0 | lib/hotels_in_iraq/hotel.rb |