Class: Neo4j::TypeConverters::TimeConverter
- Inherits:
-
Object
- Object
- Neo4j::TypeConverters::TimeConverter
- Defined in:
- lib/neo4j/type_converters/type_converters.rb
Class Method Summary collapse
- .convert?(clazz_or_symbol) ⇒ Boolean
- .index_as ⇒ Object
-
.to_java(value) ⇒ Object
Converts the given DateTime (UTC) value to an Fixnum.
- .to_ruby(value) ⇒ Object
Class Method Details
.convert?(clazz_or_symbol) ⇒ Boolean
244 245 246 |
# File 'lib/neo4j/type_converters/type_converters.rb', line 244 def convert?(clazz_or_symbol) Time == clazz_or_symbol || :time == clazz_or_symbol end |
.index_as ⇒ Object
264 265 266 |
# File 'lib/neo4j/type_converters/type_converters.rb', line 264 def index_as Fixnum end |
.to_java(value) ⇒ Object
Converts the given DateTime (UTC) value to an Fixnum. Only utc times are supported !
250 251 252 253 254 255 256 257 |
# File 'lib/neo4j/type_converters/type_converters.rb', line 250 def to_java(value) return nil if value.nil? if value.class == Date Time.utc(value.year, value.month, value.day, 0, 0, 0).to_i else value.utc.to_i end end |
.to_ruby(value) ⇒ Object
259 260 261 262 |
# File 'lib/neo4j/type_converters/type_converters.rb', line 259 def to_ruby(value) return nil if value.nil? Time.at(value).utc end |