Class: Code::Object::Time
- Inherits:
-
Code::Object
- Object
- Code::Object
- Code::Object::Time
- Defined in:
- lib/code/object/time.rb
Constant Summary collapse
- DEFAULT_ZONE =
"Etc/UTC"
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(time) ⇒ Time
constructor
A new instance of Time.
- #inspect ⇒ Object
- #to_s ⇒ Object
Methods inherited from Code::Object
#<=>, #==, #call, code_and_operator, #code_and_operator, #code_different, code_different, code_equal_equal, #code_equal_equal, #code_equal_equal_equal, code_equal_equal_equal, code_exclamation_point, #code_exclamation_point, code_exclusive_range, #code_exclusive_range, code_inclusive_range, #code_inclusive_range, code_or_operator, #code_or_operator, code_self, #code_self, code_to_string, #code_to_string, falsy?, #falsy?, hash, #hash, maybe, multi_fetch, #multi_fetch, repeat, sig, #sig, to_s, truthy?, #truthy?, |
Constructor Details
#initialize(time) ⇒ Time
Returns a new instance of Time.
10 11 12 |
# File 'lib/code/object/time.rb', line 10 def initialize(time) @raw = time end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
8 9 10 |
# File 'lib/code/object/time.rb', line 8 def raw @raw end |
Class Method Details
.call(**args) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/code/object/time.rb', line 18 def self.call(**args) operator = args.fetch(:operator, nil) case operator.to_s when "tomorrow" sig(args) code_tomorrow else super end end |
.code_tomorrow ⇒ Object
30 31 32 33 |
# File 'lib/code/object/time.rb', line 30 def self.code_tomorrow ::Time.zone ||= DEFAULT_ZONE new(::Time.zone.tomorrow.beginning_of_day) end |
.name ⇒ Object
14 15 16 |
# File 'lib/code/object/time.rb', line 14 def self.name "Time" end |