Class: UserTime
- Inherits:
-
Object
- Object
- UserTime
- Defined in:
- lib/user_time.rb
Instance Attribute Summary collapse
-
#timezone ⇒ Object
readonly
Returns the value of attribute timezone.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #date ⇒ Object
-
#initialize(user) ⇒ UserTime
constructor
A new instance of UserTime.
- #midnight(date) ⇒ Object
- #time ⇒ Object
Constructor Details
#initialize(user) ⇒ UserTime
Returns a new instance of UserTime.
6 7 8 9 |
# File 'lib/user_time.rb', line 6 def initialize(user) @user = user @timezone = ActiveSupport::TimeZone[user.prefs.time_zone] end |
Instance Attribute Details
#timezone ⇒ Object (readonly)
Returns the value of attribute timezone.
4 5 6 |
# File 'lib/user_time.rb', line 4 def timezone @timezone end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'lib/user_time.rb', line 4 def user @user end |
Instance Method Details
#date ⇒ Object
19 20 21 |
# File 'lib/user_time.rb', line 19 def date time.to_date end |
#midnight(date) ⇒ Object
11 12 13 |
# File 'lib/user_time.rb', line 11 def midnight(date) timezone.local(date.year, date.month, date.day, 0, 0, 0) end |
#time ⇒ Object
15 16 17 |
# File 'lib/user_time.rb', line 15 def time timezone.now end |