Class: Archaeo::AvailabilityResult
- Inherits:
-
Object
- Object
- Archaeo::AvailabilityResult
- Defined in:
- lib/archaeo/availability_result.rb
Overview
Model representing the result of an availability query.
Indicates whether a URL is archived and, if so, provides the closest snapshot’s archive URL and timestamp.
Instance Attribute Summary collapse
-
#archive_url ⇒ Object
readonly
Returns the value of attribute archive_url.
-
#archived_status ⇒ Object
readonly
Returns the value of attribute archived_status.
-
#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
- #available? ⇒ Boolean
-
#initialize(url:, available:, archive_url: nil, timestamp: nil, archived_status: nil) ⇒ AvailabilityResult
constructor
A new instance of AvailabilityResult.
- #inspect ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
- #unavailable? ⇒ Boolean
Constructor Details
#initialize(url:, available:, archive_url: nil, timestamp: nil, archived_status: nil) ⇒ AvailabilityResult
Returns a new instance of AvailabilityResult.
11 12 13 14 15 16 17 18 |
# File 'lib/archaeo/availability_result.rb', line 11 def initialize(url:, available:, archive_url: nil, timestamp: nil, archived_status: nil) @url = url @available = available @archive_url = archive_url @timestamp = @archived_status = archived_status end |
Instance Attribute Details
#archive_url ⇒ Object (readonly)
Returns the value of attribute archive_url.
9 10 11 |
# File 'lib/archaeo/availability_result.rb', line 9 def archive_url @archive_url end |
#archived_status ⇒ Object (readonly)
Returns the value of attribute archived_status.
9 10 11 |
# File 'lib/archaeo/availability_result.rb', line 9 def archived_status @archived_status end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
9 10 11 |
# File 'lib/archaeo/availability_result.rb', line 9 def @timestamp end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/archaeo/availability_result.rb', line 9 def url @url end |
Instance Method Details
#as_json ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/archaeo/availability_result.rb', line 46 def as_json(*) { url: @url, available: @available, archive_url: @archive_url, timestamp: @timestamp&.to_s, archived_status: @archived_status, } end |
#available? ⇒ Boolean
20 21 22 |
# File 'lib/archaeo/availability_result.rb', line 20 def available? @available end |
#inspect ⇒ Object
56 57 58 |
# File 'lib/archaeo/availability_result.rb', line 56 def inspect "#<#{self.class.name} #{@url} available=#{@available}>" end |
#to_h ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/archaeo/availability_result.rb', line 36 def to_h { url: @url, available: @available, archive_url: @archive_url, timestamp: @timestamp, archived_status: @archived_status, } end |
#to_s ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/archaeo/availability_result.rb', line 28 def to_s if available? "#{url} -> #{archive_url} (#{})" else "#{url} -> not available" end end |
#unavailable? ⇒ Boolean
24 25 26 |
# File 'lib/archaeo/availability_result.rb', line 24 def unavailable? !@available end |