Class: Zypper::Upgraderepo::PageRequest

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/zypper/upgraderepo/requests/http.rb

Overview

Base class for a Web page request.

Direct Known Subclasses

Requests::HttpRequest

Constant Summary collapse

USER_AGENT =
"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, timeout = 60) ⇒ PageRequest

Returns a new instance of PageRequest.



16
17
18
19
# File 'lib/zypper/upgraderepo/requests/http.rb', line 16

def initialize(obj, timeout = 60)
  super obj
  @timeout = timeout
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



12
13
14
# File 'lib/zypper/upgraderepo/requests/http.rb', line 12

def page
  @page
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/zypper/upgraderepo/requests/http.rb', line 21

def available?
  ping.is_a?(Net::HTTPSuccess)
end

#cache!Object



49
50
51
# File 'lib/zypper/upgraderepo/requests/http.rb', line 49

def cache!
  @page = nil
end

#forbidden?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/zypper/upgraderepo/requests/http.rb', line 37

def forbidden?
  ping.is_a?(Net::HTTPForbidden)
end

#not_found?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/zypper/upgraderepo/requests/http.rb', line 33

def not_found?
  ping.is_a?(Net::HTTPNotFound)
end

#redirected?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/zypper/upgraderepo/requests/http.rb', line 25

def redirected?
  ping.is_a?(Net::HTTPRedirection)
end

#redirected_toObject



29
30
31
# File 'lib/zypper/upgraderepo/requests/http.rb', line 29

def redirected_to
  ping["location"]
end

#statusObject



45
46
47
# File 'lib/zypper/upgraderepo/requests/http.rb', line 45

def status
  ping.class.to_s
end

#timeout?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/zypper/upgraderepo/requests/http.rb', line 41

def timeout?
  ping.is_a?(Net::HTTPRequestTimeOut)
end