Sha256: d532eb4f45b8d5ebfeb06a72aac4261b4724fd79d2d9541d3716e20e22c24a33
Contents?: true
Size: 857 Bytes
Versions: 1
Compression:
Stored size: 857 Bytes
Contents
module OData4 module Properties # Defines the Time OData4 type. class Time < OData4::Property # Returns the property value, properly typecast # @return [Time,nil] def value if (@value.nil? || @value.empty?) && allows_nil? nil else ::Time.strptime(@value, '%H:%M:%S%:z') end end # Sets the property value # @params new_value [Time] def value=(new_value) validate(new_value) @value = parse_value(new_value) end # The OData4 type name def type 'Edm.Time' end private def validate(value) unless value.is_a?(::Time) raise ArgumentError, 'Value is not a time object' end end def parse_value(value) value.strftime('%H:%M:%S%:z') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
odata4-0.7.0 | lib/odata4/properties/time.rb |