Class: Acfs::Location Private
- Inherits:
-
Object
- Object
- Acfs::Location
- Defined in:
- lib/acfs/location.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Describes a URL with placeholders.
Constant Summary collapse
- REGEXP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/^:([A-z][A-z0-9_]*)$/
Instance Attribute Summary collapse
- #arguments ⇒ Object readonly private
- #raw ⇒ Object readonly private
- #struct ⇒ Object readonly private
- #vars ⇒ Object readonly private
Instance Method Summary collapse
- #build(vars) ⇒ Object private
- #extract_from(*args) ⇒ Object private
-
#initialize(uri, vars = {}) ⇒ Location
constructor
private
A new instance of Location.
- #raw_uri ⇒ Object (also: #to_s) private
- #str ⇒ Object private
Constructor Details
#initialize(uri, vars = {}) ⇒ Location
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Location.
13 14 15 16 17 18 |
# File 'lib/acfs/location.rb', line 13 def initialize(uri, vars = {}) @raw = URI.parse uri @vars = vars @struct = raw.path.split('/').reject(&:empty?).map {|s| s =~ REGEXP ? Regexp.last_match[1].to_sym : s } @arguments = struct.select {|s| s.is_a?(Symbol) } end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/acfs/location.rb', line 9 def arguments @arguments end |
#raw ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/acfs/location.rb', line 9 def raw @raw end |
#struct ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/acfs/location.rb', line 9 def struct @struct end |
#vars ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/acfs/location.rb', line 9 def vars @vars end |
Instance Method Details
#build(vars) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/acfs/location.rb', line 20 def build(vars) self.class.new raw.to_s, vars.stringify_keys.merge(self.vars) end |
#extract_from(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 27 28 29 |
# File 'lib/acfs/location.rb', line 24 def extract_from(*args) vars = {} arguments.each {|key| vars[key.to_s] = extract_arg(key, args) } build(vars) end |
#raw_uri ⇒ Object Also known as: to_s
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 |
# File 'lib/acfs/location.rb', line 37 def raw_uri raw.to_s end |
#str ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 35 |
# File 'lib/acfs/location.rb', line 31 def str uri = raw.dup uri.path = "/#{struct.map {|s| lookup_variable(s) }.join('/')}" uri.to_s end |