class LC::Date

Date


Attributes

value[RW]

Public Class Methods

new(data) click to toggle source
# File lib/leancloud/datatypes.rb, line 75
def initialize(data)
  if data.respond_to?(:iso8601)
    @value = data
  elsif data.is_a? Hash
    @value = DateTime.parse data["iso"]
  elsif data.is_a? String
    @value = DateTime.parse data
  else
    raise "data doesn't act like time #{data.inspect}"
  end
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/leancloud/datatypes.rb, line 98
def <=>(other)
  value <=> other.value
end
==(other)
Alias for: eql?
as_json(*a)
Alias for: to_h
eql?(other) click to toggle source
# File lib/leancloud/datatypes.rb, line 87
def eql?(other)
  self.class.equal?(other.class) &&
    value == other.value
end
Also aliased as: ==
hash() click to toggle source
# File lib/leancloud/datatypes.rb, line 94
def hash
  value.hash
end
method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/leancloud/datatypes.rb, line 102
def method_missing(method, *args, &block)
  if value.respond_to?(method)
    value.send(method, *args, &block)
  else
    super(method)
  end
end
respond_to?(method, include_private = false) click to toggle source
Calls superclass method
# File lib/leancloud/datatypes.rb, line 110
def respond_to?(method, include_private = false)
  super || value.respond_to?(method, include_private)
end
to_h(*a) click to toggle source
# File lib/leancloud/datatypes.rb, line 114
def to_h(*a)
  {
      Protocol::KEY_TYPE => Protocol::TYPE_DATE,
      "iso"              => value.to_time.utc.iso8601(3)
  }
end
Also aliased as: as_json
to_json(*a) click to toggle source
# File lib/leancloud/datatypes.rb, line 122
def to_json(*a)
  to_h.to_json(*a)
end