Class: Shale::Type::Time
Overview
Cast value to Time
Class Method Summary collapse
-
.as_csv(value) ⇒ String
private
Use ISO 8601 format in CSV document.
-
.as_json(value) ⇒ String
private
Use ISO 8601 format in JSON document.
-
.as_xml_value(value) ⇒ String
private
Use ISO 8601 format in XML document.
-
.as_yaml(value) ⇒ String
private
Use ISO 8601 format in YAML document.
- .cast(value) ⇒ Time? private
Methods inherited from Value
as_hash, as_toml, as_xml, of_csv, of_hash, of_json, of_toml, of_xml, of_yaml
Class Method Details
.as_csv(value) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Use ISO 8601 format in CSV document
57 58 59 |
# File 'lib/shale/type/time.rb', line 57 def self.as_csv(value, **) value&.iso8601 end |
.as_json(value) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Use ISO 8601 format in JSON document
35 36 37 |
# File 'lib/shale/type/time.rb', line 35 def self.as_json(value, **) value&.iso8601 end |
.as_xml_value(value) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Use ISO 8601 format in XML document
68 69 70 |
# File 'lib/shale/type/time.rb', line 68 def self.as_xml_value(value) value&.iso8601 end |
.as_yaml(value) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Use ISO 8601 format in YAML document
46 47 48 |
# File 'lib/shale/type/time.rb', line 46 def self.as_yaml(value, **) value&.iso8601 end |
.cast(value) ⇒ Time?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/shale/type/time.rb', line 17 def self.cast(value) if value.is_a?(::String) return if value.empty? ::Time.parse(value) elsif value.respond_to?(:to_time) value.to_time else value end end |