Class: CalendarForm

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/forms/calendar_form.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (CalendarForm) initialize(request, attributes = {})

Returns a new instance of CalendarForm



7
8
9
# File 'app/forms/calendar_form.rb', line 7

def initialize request, attributes = {}
  super attributes.merge request: request
end

Instance Attribute Details

- (Object) current_week

Returns the value of attribute current_week



4
5
6
# File 'app/forms/calendar_form.rb', line 4

def current_week
  @current_week
end

- (Object) request

Returns the value of attribute request



5
6
7
# File 'app/forms/calendar_form.rb', line 5

def request
  @request
end

Instance Method Details

- (Object) current_week_path



15
16
17
18
19
# File 'app/forms/calendar_form.rb', line 15

def current_week_path
  path = request.query_parameters.dup
  path.delete :calendar_form
  path
end

- (Object) each_day



37
38
39
40
41
42
43
# File 'app/forms/calendar_form.rb', line 37

def each_day
  date_time = current_week.beginning_of_week
  until date_time > current_week.end_of_week
    yield date_time
    date_time += 1.day
  end
end

- (Object) each_half_hour



45
46
47
48
49
50
51
# File 'app/forms/calendar_form.rb', line 45

def each_half_hour
  time = current_week.beginning_of_day
  until time > current_week.end_of_day
    yield time
    time += 30.minutes
  end
end

- (Object) next_week



33
34
35
# File 'app/forms/calendar_form.rb', line 33

def next_week
  current_week + 1.week
end

- (Object) next_week_path



25
26
27
# File 'app/forms/calendar_form.rb', line 25

def next_week_path
  request.query_parameters.merge calendar_form: { current_week: next_week }
end

- (Object) previous_week



29
30
31
# File 'app/forms/calendar_form.rb', line 29

def previous_week
  current_week - 1.week
end

- (Object) previous_week_path



21
22
23
# File 'app/forms/calendar_form.rb', line 21

def previous_week_path
  request.query_parameters.merge calendar_form: { current_week: previous_week }
end