Class: Rosendo::Routes::Route::Path::URL

Inherits:
Object
  • Object
show all
Defined in:
lib/rosendo/routes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ URL

Returns a new instance of URL.



68
69
70
71
# File 'lib/rosendo/routes.rb', line 68

def initialize(url)
  @url = url
  @path, @query = url.split('?')
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



67
68
69
# File 'lib/rosendo/routes.rb', line 67

def path
  @path
end

#queryObject (readonly)

Returns the value of attribute query.



67
68
69
# File 'lib/rosendo/routes.rb', line 67

def query
  @query
end

#urlObject (readonly)

Returns the value of attribute url.



67
68
69
# File 'lib/rosendo/routes.rb', line 67

def url
  @url
end

Instance Method Details

#query_paramsObject



73
74
75
76
77
78
79
80
81
# File 'lib/rosendo/routes.rb', line 73

def query_params
  return {} unless query
  {}.tap do |params|
    query.split('&').each do |pair|
      k, v = pair.split('=')
      params[k.to_sym] = v
    end
  end
end