Class: Typhoid::Uri
- Inherits:
-
Object
- Object
- Typhoid::Uri
- Defined in:
- lib/typhoid/uri.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Instance Method Summary collapse
-
#initialize(*paths) ⇒ Uri
constructor
A new instance of Uri.
- #join(*more_paths) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(*paths) ⇒ Uri
Returns a new instance of Uri.
12 13 14 15 16 17 |
# File 'lib/typhoid/uri.rb', line 12 def initialize(*paths) self.base = URI.parse paths.shift.to_s self.paths = sanitize(base.path) + sanitize(paths) base.path = "" raise "Invalid Base on #uri_join: #{base}" unless base.scheme || base.host end |
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
9 10 11 |
# File 'lib/typhoid/uri.rb', line 9 def base @base end |
#paths ⇒ Object
Returns the value of attribute paths.
10 11 12 |
# File 'lib/typhoid/uri.rb', line 10 def paths @paths end |
Instance Method Details
#join(*more_paths) ⇒ Object
19 20 21 22 |
# File 'lib/typhoid/uri.rb', line 19 def join(*more_paths) full_path = (paths + sanitize(more_paths)).join "/" base.clone.merge(full_path).to_s end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/typhoid/uri.rb', line 24 def to_s join end |