Class: PerfectTOML::LocalDateTimeBase

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/perfect_toml.rb

Direct Known Subclasses

LocalDate, LocalDateTime, LocalTime

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/perfect_toml.rb', line 50

def <=>(other)
  return nil if self.class != other.class
  [:year, :month, :day, :hour, :min, :sec].each do |key|
    next unless respond_to?(key)
    cmp = send(key) <=> other.send(key)
    return cmp if cmp != 0
  end
  return 0
end

#==(other) ⇒ Object



41
42
43
44
45
46
# File 'lib/perfect_toml.rb', line 41

def ==(other)
  self.class == other.class &&
    [:year, :month, :day, :hour, :min, :sec].all? do |key|
      !respond_to?(key) || (send(key) == other.send(key))
    end
end

#inspectObject



33
34
35
# File 'lib/perfect_toml.rb', line 33

def inspect
  "#<#{ self.class } #{ to_s }>"
end

#pretty_print(q) ⇒ Object



37
38
39
# File 'lib/perfect_toml.rb', line 37

def pretty_print(q)
  q.text inspect
end

#to_inline_tomlObject



29
30
31
# File 'lib/perfect_toml.rb', line 29

def to_inline_toml
  to_s
end