Class: Neo4j::Driver::Types::Time

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/neo4j/driver/types/time.rb

Direct Known Subclasses

LocalDateTime, LocalTime, OffsetTime

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time) ⇒ Time

Returns a new instance of Time.



17
18
19
# File 'lib/neo4j/driver/types/time.rb', line 17

def initialize(time)
  @time = time
end

Class Method Details

.parse(date) ⇒ Object



12
13
14
# File 'lib/neo4j/driver/types/time.rb', line 12

def parse(date)
  new(::Time.parse(date))
end

Instance Method Details

#+(numeric) ⇒ Object



37
38
39
# File 'lib/neo4j/driver/types/time.rb', line 37

def +(numeric)
  self.class.new(@time + numeric)
end

#<=>(other) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/neo4j/driver/types/time.rb', line 25

def <=>(other)
  return unless other.is_a?(self.class)

  self.class.significant_fields.reduce(0) do |acc, elem|
    acc.zero? ? send(elem) <=> other.send(elem) : (break acc)
  end
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/neo4j/driver/types/time.rb', line 33

def eql?(other)
  other.is_a?(self.class) && self.class.significant_fields.all? { |elem| send(elem).eql?(other.send(elem)) }
end

#significantObject



21
22
23
# File 'lib/neo4j/driver/types/time.rb', line 21

def significant
  self.class.significant_fields.map(&method(:send))
end