diff options
| author | Xinhui | 2017-05-15 11:32:56 +0200 | 
|---|---|---|
| committer | Xinhui | 2017-05-15 11:50:25 +0200 | 
| commit | 2c32ac2a3372dfaee531734d3cf94f6b522b7c1b (patch) | |
| tree | c11ebe9672e36d607e562788b555460ebcadeb39 /app/models/calendar.rb | |
| parent | 8cfb32a40ae3f2c48c6a7884a1a8251ee4a48254 (diff) | |
| download | chouette-core-2c32ac2a3372dfaee531734d3cf94f6b522b7c1b.tar.bz2 | |
Calendar #convert_to_time_tablet
Refs #3372
Diffstat (limited to 'app/models/calendar.rb')
| -rw-r--r-- | app/models/calendar.rb | 11 | 
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/calendar.rb b/app/models/calendar.rb index 91a17e853..39e0d6d49 100644 --- a/app/models/calendar.rb +++ b/app/models/calendar.rb @@ -19,6 +19,17 @@ class Calendar < ActiveRecord::Base      [:contains_date]    end +  def convert_to_time_table +    Chouette::TimeTable.new.tap do |tt| +      self.dates.each do |d| +        tt.dates << Chouette::TimeTableDate.new(date: d, in_out: true) +      end +      self.date_ranges.each do |p| +        tt.periods << Chouette::TimeTablePeriod.new(period_start: p.begin, period_end: p.end) +      end +    end +  end +    class Period      include ActiveAttr::Model  | 
