Module: Wayback::API::Archive
Instance Method Summary collapse
-
#list(url, options = {}) ⇒ Wayback::Archive
Return a list of archived pages.
-
#page(url, date = 0, options = {}) ⇒ Wayback::Page
Returns the HTML contents of an archive page, fetched by date.
Instance Method Details
#list(url, options = {}) ⇒ Wayback::Archive
Return a list of archived pages
17 18 19 |
# File 'lib/wayback/api/archive.rb', line 17 def list(url, ={}) object_from_response(Wayback::Archive, :get, "/timemap/link/#{url}", ) end |
#page(url, date = 0, options = {}) ⇒ Wayback::Page
Returns the HTML contents of an archive page, fetched by date
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/wayback/api/archive.rb', line 34 def page(url, date=0, ={}) archive_date = case date.class.to_s when 'Time' date when 'Date', 'DateTime' date.to_time when 'Symbol' (date == :first ? 0 : Time.now) when 'String' Time.parse(date).strftime('%Y%m%d%H%M%S') when 'Fixnum', 'Integer', 'Float' # Epoch vs date string as number (date.to_i <= Time.now.to_i ? Time.at(date.to_i) : Time.parse(date.to_i.to_s)) else raise Wayback::Error::ClientError end # Format accordingly archive_date = archive_date.strftime('%Y%m%d%H%M%S') if archive_date.class == Time # Get it object_from_response(Wayback::Page, :get, "/#{archive_date}/#{url}", ) end |