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.
11 12 13 |
# File 'lib/json/add/date.rb', line 11 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.
19 20 21 22 23 24 25 26 27 |
# File 'lib/json/add/date.rb', line 19 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
31 32 33 |
# File 'lib/json/add/date.rb', line 31 def to_json(*args) as_json.to_json(*args) end |