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
243 244 245 |
# File 'lib/neo4j/type_converters/type_converters.rb', line 243 def convert?(clazz_or_symbol) Time == clazz_or_symbol || :time == clazz_or_symbol end |
.index_as ⇒ Object
263 264 265 |
# File 'lib/neo4j/type_converters/type_converters.rb', line 263 def index_as Fixnum end |
.to_java(value) ⇒ Object
Converts the given DateTime (UTC) value to an Fixnum. Only utc times are supported !
249 250 251 252 253 254 255 256 |
# File 'lib/neo4j/type_converters/type_converters.rb', line 249 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
258 259 260 261 |
# File 'lib/neo4j/type_converters/type_converters.rb', line 258 def to_ruby(value) return nil if value.nil? Time.at(value).utc end |