Class: Shrinker::EasyUrl

Inherits:
Struct
  • Object
show all
Defined in:
lib/shrinker/easy_url.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



2
3
4
# File 'lib/shrinker/easy_url.rb', line 2

def attributes
  @attributes
end

#urlObject

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url



2
3
4
# File 'lib/shrinker/easy_url.rb', line 2

def url
  @url
end

Instance Method Details

#=~(regexp) ⇒ Object



5
6
7
# File 'lib/shrinker/easy_url.rb', line 5

def =~(regexp)
  to_s =~ regexp
end

#paramsObject



15
16
17
18
19
20
21
22
23
# File 'lib/shrinker/easy_url.rb', line 15

def params
  @params ||= begin
    hash = {}
    CGI.parse(parsed_uri.query).each_pair do |key, value|
      hash[key.to_sym] = value.length == 1 ? value.first : value
    end if parsed_uri.query
    hash
  end
end

#to_sObject



9
10
11
12
13
# File 'lib/shrinker/easy_url.rb', line 9

def to_s
  parsed_uri.query = to_param
  parsed_uri.query = nil if parsed_uri.query == ''
  parsed_uri.to_s
end