Class: Twitterscraper::Cache::Entry
- Inherits:
-
Hash
- Object
- Hash
- Twitterscraper::Cache::Entry
- Defined in:
- lib/twitterscraper/cache.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #attrs ⇒ Object
-
#initialize(key, value, time) ⇒ Entry
constructor
A new instance of Entry.
- #to_json ⇒ Object
Constructor Details
#initialize(key, value, time) ⇒ Entry
Returns a new instance of Entry.
57 58 59 60 61 |
# File 'lib/twitterscraper/cache.rb', line 57 def initialize(key, value, time) @key = key @value = value @time = time end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
55 56 57 |
# File 'lib/twitterscraper/cache.rb', line 55 def key @key end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
55 56 57 |
# File 'lib/twitterscraper/cache.rb', line 55 def time @time end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
55 56 57 |
# File 'lib/twitterscraper/cache.rb', line 55 def value @value end |
Class Method Details
.from_json(text) ⇒ Object
74 75 76 77 |
# File 'lib/twitterscraper/cache.rb', line 74 def from_json(text) json = JSON.parse(text) new(json['key'], Base64.decode64(json['value']), Time.parse(json['time'])) end |
Instance Method Details
#attrs ⇒ Object
63 64 65 |
# File 'lib/twitterscraper/cache.rb', line 63 def attrs {key: @key, value: @value, time: @time} end |
#to_json ⇒ Object
67 68 69 70 71 |
# File 'lib/twitterscraper/cache.rb', line 67 def to_json hash = attrs hash[:value] = Base64.encode64(hash[:value]) hash.to_json end |