Class: Neo4j::Driver::Types::TemporalValue
- Inherits:
-
Object
- Object
- Neo4j::Driver::Types::TemporalValue
show all
- Includes:
- Comparable
- Defined in:
- lib/neo4j/driver/types/temporal_value.rb
Overview
Shared base for the Bolt temporal value types: Duration,
LocalDateTime, LocalTime, OffsetTime. Each subclass declares its
significant_fields and gets <=>, ==, eql?, hash derived
from them automatically. Comparable mixed in here gives <, >,
between?, clamp etc. for free.
Constant Summary
collapse
- NANOS_PER_SECOND =
1_000_000_000
- NANOS_PER_MINUTE =
60 * NANOS_PER_SECOND
- NANOS_PER_HOUR =
60 * NANOS_PER_MINUTE
- NANOS_PER_DAY =
24 * NANOS_PER_HOUR
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.significant_fields ⇒ Object
19
20
21
|
# File 'lib/neo4j/driver/types/temporal_value.rb', line 19
def self.significant_fields
raise NotImplementedError, "#{self} must define .significant_fields"
end
|
Instance Method Details
#<=>(other) ⇒ Object
27
28
29
30
|
# File 'lib/neo4j/driver/types/temporal_value.rb', line 27
def <=>(other)
return nil unless other.is_a?(self.class)
significant <=> other.significant
end
|
#==(other) ⇒ Object
Also known as:
eql?
32
33
34
|
# File 'lib/neo4j/driver/types/temporal_value.rb', line 32
def ==(other)
other.is_a?(self.class) && significant == other.significant
end
|
#hash ⇒ Object
37
38
39
|
# File 'lib/neo4j/driver/types/temporal_value.rb', line 37
def hash
significant.hash
end
|
#significant ⇒ Object
23
24
25
|
# File 'lib/neo4j/driver/types/temporal_value.rb', line 23
def significant
self.class.significant_fields.map { send(it) }
end
|