Class: NewsFetcher::History::Entry
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- NewsFetcher::History::Entry
- Defined in:
- lib/newsfetcher/history.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_json(data) ⇒ Object
81 82 83 84 85 |
# File 'lib/newsfetcher/history.rb', line 81 def self.from_json(data) json = JSON.parse(data, symbolize_names: true) self.parse_json(json) new(**json) end |
.parse_json(json) ⇒ Object
87 88 89 |
# File 'lib/newsfetcher/history.rb', line 87 def self.parse_json(json) json[:time] = Time.at(json[:time]) end |
Instance Method Details
#to_json(*opts) ⇒ Object
91 92 93 94 95 |
# File 'lib/newsfetcher/history.rb', line 91 def to_json(*opts) h = to_h h[:time] = h[:time].to_i h.to_json(*opts) end |