Class: URL

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/remotely/ext/url.rb

Instance Method Summary collapse

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_sObject



23
24
25
# File 'lib/remotely/ext/url.rb', line 23

def to_s
  @url
end