Class: Date
- Inherits:
-
Object
- Object
- Date
- Defined in:
- lib/json/add/date.rb
Overview
Date serialization/deserialization
Class Method Summary collapse
-
.json_create(object) ⇒ Object
Deserializes JSON string by converting Julian year
y
, monthm
, dayd
and Day of Calendar Reformsg
to Date.
Instance Method Summary collapse
-
#as_json ⇒ Object
Returns a hash, that will be turned into a JSON object and represent this object.
-
#to_json(*args) ⇒ Object
Stores class name (Date) with Julian year
y
, monthm
, dayd
and Day of Calendar Reformsg
as JSON string.
Class Method Details
.json_create(object) ⇒ Object
Deserializes JSON string by converting Julian year y
, month m
, day d
and Day of Calendar Reform sg
to Date.
12 13 14 |
# File 'lib/json/add/date.rb', line 12 def self.json_create(object) civil(*object.values_at('y', 'm', 'd', 'sg')) end |
Instance Method Details
#as_json ⇒ Object
Returns a hash, that will be turned into a JSON object and represent this object.
20 21 22 23 24 25 26 27 28 |
# File 'lib/json/add/date.rb', line 20 def as_json(*) { JSON.create_id => self.class.name, 'y' => year, 'm' => month, 'd' => day, 'sg' => start, } end |
#to_json(*args) ⇒ Object
Stores class name (Date) with Julian year y
, month m
, day d
and Day of Calendar Reform sg
as JSON string
32 33 34 |
# File 'lib/json/add/date.rb', line 32 def to_json(*args) as_json.to_json(*args) end |