Class: RWB::Url
- Inherits:
-
Object
- Object
- RWB::Url
- Defined in:
- lib/rwb/url.rb
Overview
Direct Known Subclasses
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
-
#initialize(weight, url, method = 'GET') ⇒ Url
constructor
A new instance of Url.
- #read_method(method = 'GET') ⇒ Object
-
#to_base ⇒ Object
to_base returns a string suitable for creating a
Regexp
to match against. - #to_s ⇒ Object
-
#to_url ⇒ Object
to_url returns the URL to be requested as a string.
Constructor Details
#initialize(weight, url, method = 'GET') ⇒ Url
Returns a new instance of Url.
12 13 14 15 16 |
# File 'lib/rwb/url.rb', line 12 def initialize(weight, url, method='GET') @weight = weight @url = url @method = read_method(method) end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
10 11 12 |
# File 'lib/rwb/url.rb', line 10 def method @method end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
10 11 12 |
# File 'lib/rwb/url.rb', line 10 def weight @weight end |
Instance Method Details
#read_method(method = 'GET') ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/rwb/url.rb', line 18 def read_method(method = 'GET') method = method.to_s.upcase if method != 'GET' && method != 'POST' return 'GET' else return method end end |
#to_base ⇒ Object
to_base returns a string suitable for creating a Regexp
to match against.
url.to_base # => "http://www.example.com "
40 41 42 |
# File 'lib/rwb/url.rb', line 40 def to_base @url end |
#to_s ⇒ Object
44 45 46 |
# File 'lib/rwb/url.rb', line 44 def to_s @weight.to_s + " " + @url end |
#to_url ⇒ Object
to_url returns the URL to be requested as a string
url.to_url # => "http://www.example.com"
30 31 32 |
# File 'lib/rwb/url.rb', line 30 def to_url @url end |