Class Price
In: app/models/price.rb
Parent: ActiveRecord::Base

************************************************************************/

  • SOLUNAS BOOKING ENGINE */
  • ====================== */
  • */
  • Copyright © 2006 by Marc Isemann */
  • sourceforge.net/projects/solunas */
  • */
  • This program is free software. You can redistribute it and/or modify */
  • it under the terms of the GNU General Public License as published by */
  • the Free Software Foundation; either version 2 of the License. */

************************************************************************/

Methods

Public Class methods

return an 2D array of default price Array[month][day_of_month] = defalt

[Source]

    # File app/models/price.rb, line 19
19:                 def self.get_default_price(default)   
20:                                 
21:                                 months = Hash.new
22:                                 month_data = Hash.new
23:                                 
24:                                         (1 .. 12).each do |month|
25:                                                 days = Hash.new
26:                                                         (1 .. 31).each do |day|
27:                                                                 
28:                                                                 days["#{day}"] = default
29:                                                                 
30:                                                 end
31:                                                 months["#{month}"] = days
32:                                 end
33:                                 return months
34:                 end

Set a new price in the price array

[Source]

    # File app/models/price.rb, line 37
37:                 def self.new_price(price, start_day, start_month, stop_day, stop_month, new_price)
38:                         prl = price.price
39:                                 convert_start = ::Time.local(*ParseDate.parsedate("2000-" + start_month + "-" + start_day))
40:                 convert_stop = ::Time.local(*ParseDate.parsedate("2000-" + stop_month + "-" + stop_day))             
41:                 counter = convert_start
42:                                 
43:                                 while counter <= convert_stop do
44:                                                 prl["#{counter.month}"]["#{counter.mday}"] = new_price    
45:                                                 counter = counter + 1.day                                 
46:                                 end
47:                                 return prl
48:                 end

[Validate]