Class: Barometer::Utils::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/barometer/utils/address.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, query = {}) ⇒ Address

Returns a new instance of Address.



6
7
8
9
# File 'lib/barometer/utils/address.rb', line 6

def initialize(url, query={})
  @address = Addressable::URI.parse(url)
  add(query) unless query.blank?
end

Instance Method Details

#add(addition) ⇒ Object



19
20
21
22
# File 'lib/barometer/utils/address.rb', line 19

def add(addition)
  current_values = address.query_values || {}
  address.query_values = current_values.merge(addition)
end

#queryObject



11
12
13
# File 'lib/barometer/utils/address.rb', line 11

def query
  address.query_values
end

#to_sObject



24
25
26
# File 'lib/barometer/utils/address.rb', line 24

def to_s
  address.to_s
end

#urlObject



15
16
17
# File 'lib/barometer/utils/address.rb', line 15

def url
  address.omit(:query).to_s
end