Class: Mack::Request::DateTimeParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/mack/controller/request/date_time_parameter.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDateTimeParameter

Returns a new instance of DateTimeParameter.



13
14
15
16
17
18
19
20
# File 'lib/mack/controller/request/date_time_parameter.rb', line 13

def initialize
  self.year = Time.now.year
  self.month = 1
  self.day = 1
  self.hour = 0
  self.minute = 0
  self.second = 0
end

Instance Attribute Details

#dayObject

Returns the value of attribute day.



8
9
10
# File 'lib/mack/controller/request/date_time_parameter.rb', line 8

def day
  @day
end

#hourObject

Returns the value of attribute hour.



9
10
11
# File 'lib/mack/controller/request/date_time_parameter.rb', line 9

def hour
  @hour
end

#minuteObject

Returns the value of attribute minute.



10
11
12
# File 'lib/mack/controller/request/date_time_parameter.rb', line 10

def minute
  @minute
end

#monthObject

Returns the value of attribute month.



7
8
9
# File 'lib/mack/controller/request/date_time_parameter.rb', line 7

def month
  @month
end

#secondObject

Returns the value of attribute second.



11
12
13
# File 'lib/mack/controller/request/date_time_parameter.rb', line 11

def second
  @second
end

#yearObject

Returns the value of attribute year.



6
7
8
# File 'lib/mack/controller/request/date_time_parameter.rb', line 6

def year
  @year
end

Instance Method Details

#add(key, value) ⇒ Object



22
23
24
# File 'lib/mack/controller/request/date_time_parameter.rb', line 22

def add(key, value)
  self.send("#{key}=", value)
end

#to_sObject



26
27
28
# File 'lib/mack/controller/request/date_time_parameter.rb', line 26

def to_s
  "#{year}-#{month}-#{day} #{hour}:#{minute}:#{second}"
end

#to_timeObject



30
31
32
# File 'lib/mack/controller/request/date_time_parameter.rb', line 30

def to_time
  Time.parse(self.to_s)
end