Class: Url
- Inherits:
-
Object
- Object
- Url
- Defined in:
- lib/crawler_sample/url.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(values = {}) ⇒ Url
constructor
A new instance of Url.
- #valid? ⇒ Boolean
Constructor Details
#initialize(values = {}) ⇒ Url
Returns a new instance of Url.
3 4 5 6 7 |
# File 'lib/crawler_sample/url.rb', line 3 def initialize(values = {}) values.each do |k, v| self.send("#{k}=", v) end end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
2 3 4 |
# File 'lib/crawler_sample/url.rb', line 2 def host @host end |
#scheme ⇒ Object
Returns the value of attribute scheme.
2 3 4 |
# File 'lib/crawler_sample/url.rb', line 2 def scheme @scheme end |
#value ⇒ Object
Returns the value of attribute value.
2 3 4 |
# File 'lib/crawler_sample/url.rb', line 2 def value @value end |
Instance Method Details
#valid? ⇒ Boolean
9 10 11 12 13 14 15 16 17 |
# File 'lib/crawler_sample/url.rb', line 9 def valid? begin uri = URI.parse(self.value) resp = uri.kind_of?(URI::HTTP) return resp rescue URI::InvalidURIError return false end end |