class Parse::ParseDate
Attributes
time[RW]
Public Class Methods
new(hash={})
click to toggle source
# File lib/parse/date.rb, line 20 def initialize hash={} hash = string_keyed_hash hash @raw_hash = hash @time = ::Time.parse hash['iso'] if hash.has_key? 'iso' end
parse(*args)
click to toggle source
# File lib/parse/date.rb, line 7 def parse *args if args.size == 1 && args.first.is_a?(String) new :iso => args.first else new.tap do |dt| dt.time = Time.gm *args end end end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/parse/date.rb, line 26 def <=> other self.time <=> other.time end
method_missing(name, *args, &block)
click to toggle source
# File lib/parse/date.rb, line 45 def method_missing name, *args, &block @time.__send__ name, *args, &block end
to_h()
click to toggle source
# File lib/parse/date.rb, line 30 def to_h { "__type" => "Date", "iso" => @time.iso8601 } end
to_json(*args)
click to toggle source
# File lib/parse/date.rb, line 37 def to_json *args to_h.to_json end
to_s()
click to toggle source
# File lib/parse/date.rb, line 41 def to_s to_json end