Class: KDL::Types::Time
- Inherits:
-
Value::Custom
- Object
- Value
- Value::Custom
- KDL::Types::Time
- Defined in:
- lib/kdl/types/date_time.rb
Constant Summary collapse
- REGEX =
TODO: this is not a perfect ISO8601 time string
/^T?((?:2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]+)?(?:Z|[+-]\d\d:\d\d)?)$/
Constants inherited from Value
Instance Attribute Summary
Attributes inherited from Value::Custom
Attributes inherited from Value
Class Method Summary collapse
Methods inherited from Value::Custom
Methods inherited from Value
#==, #as_type, from, #initialize, #inspect, #method_missing, #respond_to_missing?, #stringify_value, #to_s, #to_v2, #version
Constructor Details
This class inherits a constructor from KDL::Value
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class KDL::Value
Class Method Details
.call(value, type = 'time') ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/kdl/types/date_time.rb', line 21 def self.call(value, type = 'time') return nil unless value.is_a? ::KDL::Value::String match = REGEX.match(value.value) raise ArgumentError, 'invalid time' if match.nil? time = ::Time.iso8601("#{::Date.today.iso8601}T#{match[1]}") new(time, type: type) end |