Class: DateTime

Inherits:
Object
  • Object
show all
Defined in:
lib/jinx/json/date.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.json_create(json) ⇒ Date

Returns the deserialized object.

Parameters:

  • json (String)

    the JSON to deserialize

Returns:

  • (Date)

    the deserialized object



7
8
9
# File 'lib/jinx/json/date.rb', line 7

def self.json_create(json)
  parse(json['data'])
end

Instance Method Details

#to_json(*args) ⇒ String

Adds JSON serialization to Ruby Date.

Parameters:

  • args

    the JSON serialization options

Returns:

  • (String)

    the serialized date



15
16
17
18
19
20
# File 'lib/jinx/json/date.rb', line 15

def to_json(*args)
  {
    'json_class' => self.class.name,
    'data' => to_s
  }.to_json(*args)
end