Class: Linkser::Object
- Inherits:
-
Object
- Object
- Linkser::Object
- Defined in:
- lib/linkser/object.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#head ⇒ Object
readonly
Returns the value of attribute head.
-
#last_url ⇒ Object
readonly
Returns the value of attribute last_url.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #body ⇒ Object
- #build_body ⇒ Object
-
#initialize(url, last_url, head, options = {}) ⇒ Object
constructor
A new instance of Object.
Constructor Details
#initialize(url, last_url, head, options = {}) ⇒ Object
Returns a new instance of Object.
8 9 10 11 12 13 |
# File 'lib/linkser/object.rb', line 8 def initialize url, last_url, head, ={} @url = url @last_url = last_url @head = head @options = end |
Instance Attribute Details
#head ⇒ Object (readonly)
Returns the value of attribute head.
6 7 8 |
# File 'lib/linkser/object.rb', line 6 def head @head end |
#last_url ⇒ Object (readonly)
Returns the value of attribute last_url.
6 7 8 |
# File 'lib/linkser/object.rb', line 6 def last_url @last_url end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/linkser/object.rb', line 6 def url @url end |
Instance Method Details
#body ⇒ Object
15 16 17 |
# File 'lib/linkser/object.rb', line 15 def body @body ||= build_body end |
#build_body ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/linkser/object.rb', line 19 def build_body uri = URI.parse last_url if uri.scheme and (uri.scheme.eql? "http" or uri.scheme.eql? "https") http = Net::HTTP.new uri.host, uri.port if uri.scheme.eql? "https" unless @options[:ssl_verify]==true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end http.use_ssl = true end else raise 'URI ' + uri.to_s + ' is not supported by Linkser' end http.start do |agent| request = Net::HTTP::Get.new uri.request_uri response = http.request request return response.body end end |