Class: SimpleUrl::Url
- Inherits:
-
Object
- Object
- SimpleUrl::Url
- Defined in:
- lib/simple_url.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#query ⇒ Object
Returns the value of attribute query.
-
#query_string_class ⇒ Object
readonly
Returns the value of attribute query_string_class.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #append_path(path) ⇒ Object
-
#initialize(url, query_string_class) ⇒ Url
constructor
A new instance of Url.
- #normalize_path ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(url, query_string_class) ⇒ Url
10 11 12 13 14 15 |
# File 'lib/simple_url.rb', line 10 def initialize(url, query_string_class) @url = URI(url) @path = Pathname.new(@url.path) @query_string_class = query_string_class @query = query_string_class.from_string(@url.query) end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
7 8 9 |
# File 'lib/simple_url.rb', line 7 def path @path end |
#query ⇒ Object
Returns the value of attribute query.
7 8 9 |
# File 'lib/simple_url.rb', line 7 def query @query end |
#query_string_class ⇒ Object (readonly)
Returns the value of attribute query_string_class.
8 9 10 |
# File 'lib/simple_url.rb', line 8 def query_string_class @query_string_class end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/simple_url.rb', line 7 def url @url end |
Instance Method Details
#append_path(path) ⇒ Object
17 18 19 |
# File 'lib/simple_url.rb', line 17 def append_path(path) @path = @path.join(path) end |
#normalize_path ⇒ Object
21 22 23 |
# File 'lib/simple_url.rb', line 21 def normalize_path @path = @path.cleanpath end |
#to_s ⇒ Object
25 26 27 28 29 30 |
# File 'lib/simple_url.rb', line 25 def to_s q = @query.to_s @url.query = q unless q.empty? @url.path = @path.to_s @url.to_s end |