Class: Archaeo::SaveResult
- Inherits:
-
Object
- Object
- Archaeo::SaveResult
- Defined in:
- lib/archaeo/save_result.rb
Overview
Model representing the outcome of a SavePageNow request.
Contains the resulting archive URL, timestamp, and whether the page was already cached in the archive.
Instance Attribute Summary collapse
-
#archive_url ⇒ Object
readonly
Returns the value of attribute archive_url.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #as_json ⇒ Object
- #cached? ⇒ Boolean
-
#initialize(url:, archive_url:, timestamp:, cached:) ⇒ SaveResult
constructor
A new instance of SaveResult.
- #inspect ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(url:, archive_url:, timestamp:, cached:) ⇒ SaveResult
Returns a new instance of SaveResult.
11 12 13 14 15 16 |
# File 'lib/archaeo/save_result.rb', line 11 def initialize(url:, archive_url:, timestamp:, cached:) @url = url @archive_url = archive_url @timestamp = Timestamp.coerce() @cached = cached end |
Instance Attribute Details
#archive_url ⇒ Object (readonly)
Returns the value of attribute archive_url.
9 10 11 |
# File 'lib/archaeo/save_result.rb', line 9 def archive_url @archive_url end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
9 10 11 |
# File 'lib/archaeo/save_result.rb', line 9 def @timestamp end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/archaeo/save_result.rb', line 9 def url @url end |
Instance Method Details
#as_json ⇒ Object
27 28 29 30 |
# File 'lib/archaeo/save_result.rb', line 27 def as_json(*) { url: @url, archive_url: @archive_url, timestamp: @timestamp.to_s, cached: @cached } end |
#cached? ⇒ Boolean
18 19 20 |
# File 'lib/archaeo/save_result.rb', line 18 def cached? @cached end |
#inspect ⇒ Object
37 38 39 |
# File 'lib/archaeo/save_result.rb', line 37 def inspect "#<#{self.class.name} #{@url} cached=#{@cached}>" end |
#to_h ⇒ Object
22 23 24 25 |
# File 'lib/archaeo/save_result.rb', line 22 def to_h { url: @url, archive_url: @archive_url, timestamp: @timestamp, cached: @cached } end |
#to_s ⇒ Object
32 33 34 35 |
# File 'lib/archaeo/save_result.rb', line 32 def to_s label = @cached ? "Cached" : "Saved" "#{label}: #{@archive_url}" end |