Class: Broadway::Uri
- Inherits:
-
Object
- Object
- Broadway::Uri
- Defined in:
- lib/broadway/resources/uri.rb
Instance Method Summary collapse
- #host ⇒ Object
- #http? ⇒ Boolean
- #https? ⇒ Boolean
-
#initialize(url, query = {}) ⇒ Uri
constructor
A new instance of Uri.
- #path ⇒ Object
- #query ⇒ Object
- #query_hash ⇒ Object
- #scheme ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(url, query = {}) ⇒ Uri
Returns a new instance of Uri.
3 4 5 6 7 8 9 10 11 |
# File 'lib/broadway/resources/uri.rb', line 3 def initialize(url, query = {}) unless query.blank? url << "?" unless url =~ /\?/ url << query.map do |k, v| url << "#{k}=#{v}" end.join("&") end @uri = URI.parse(url) end |
Instance Method Details
#host ⇒ Object
25 26 27 |
# File 'lib/broadway/resources/uri.rb', line 25 def host uri.host end |
#http? ⇒ Boolean
29 30 31 |
# File 'lib/broadway/resources/uri.rb', line 29 def http? scheme == "http" end |
#https? ⇒ Boolean
33 34 35 |
# File 'lib/broadway/resources/uri.rb', line 33 def https? scheme == "https" end |
#path ⇒ Object
21 22 23 |
# File 'lib/broadway/resources/uri.rb', line 21 def path uri.path end |
#query ⇒ Object
41 42 43 |
# File 'lib/broadway/resources/uri.rb', line 41 def query uri.query end |
#query_hash ⇒ Object
45 46 47 |
# File 'lib/broadway/resources/uri.rb', line 45 def query_hash @query_hash ||= Broadway::Utils.parse_query(query) end |
#scheme ⇒ Object
37 38 39 |
# File 'lib/broadway/resources/uri.rb', line 37 def scheme uri.scheme end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/broadway/resources/uri.rb', line 17 def to_s url end |
#url ⇒ Object
13 14 15 |
# File 'lib/broadway/resources/uri.rb', line 13 def url @uri.to_s end |