Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/frivol.rb
Overview
Time
An extension to the Time class which allows Time instances to be serialized by #to_json
and deserialized by JSON#parse
.
Class Method Summary collapse
-
.json_create(o) ⇒ Object
Deserialize from JSON.
Instance Method Summary collapse
-
#to_json(*a) ⇒ Object
Serialize to JSON.
Class Method Details
.json_create(o) ⇒ Object
Deserialize from JSON
424 425 426 |
# File 'lib/frivol.rb', line 424 def self.json_create(o) Time.parse(*o['data']) end |
Instance Method Details
#to_json(*a) ⇒ Object
Serialize to JSON
416 417 418 419 420 421 |
# File 'lib/frivol.rb', line 416 def to_json(*a) { 'json_class' => self.class.name, 'data' => self.to_s }.to_json(*a) end |