Class: URL
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #<=>(other) ⇒ Object
-
#initialize(*args) ⇒ URL
constructor
A new instance of URL.
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ URL
Returns a new instance of URL.
4 5 6 7 8 9 |
# File 'lib/remotely/ext/url.rb', line 4 def initialize(*args) @url = "/" + args.flatten.compact.join("/") @url.gsub! %r[/{2,}], "/" @url.gsub! %r[/$], "" define_delegation_methods end |
Instance Method Details
#+(other) ⇒ Object
11 12 13 |
# File 'lib/remotely/ext/url.rb', line 11 def +(other) URL.new(to_s, other.to_s) end |
#-(other) ⇒ Object
15 16 17 |
# File 'lib/remotely/ext/url.rb', line 15 def -(other) URL.new(to_s.gsub(other.to_s, "")) end |
#<=>(other) ⇒ Object
19 20 21 |
# File 'lib/remotely/ext/url.rb', line 19 def <=>(other) @url <=> other.to_s end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/remotely/ext/url.rb', line 23 def to_s @url end |