Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/kayak.rb

Instance Method Summary collapse

Instance Method Details

#to_dateObject



19
20
21
22
23
24
25
26
# File 'lib/kayak.rb', line 19

def to_date
  date = symbolize_keys
  [:year, :month, :day].each do |key| 
    raise ArgumentError, "Cannot convert to Date, missing #{key}" if !date.has_key?(key)
    date[key] = date[key].to_i
  end
  Date.new(date[:year], date[:month], date[:day])
end