Class: Restfulness::Path
- Inherits:
-
Object
- Object
- Restfulness::Path
- Defined in:
- lib/restfulness/path.rb
Overview
The Path object is provided in request objects to provide easy access to parameters included in the URI's path.
Instance Attribute Summary collapse
-
#components ⇒ Object
Returns the value of attribute components.
-
#params ⇒ Object
Returns the value of attribute params.
-
#route ⇒ Object
Returns the value of attribute route.
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#initialize(route, string) ⇒ Path
constructor
A new instance of Path.
- #to_s ⇒ Object
Constructor Details
#initialize(route, string) ⇒ Path
Returns a new instance of Path.
10 11 12 13 14 |
# File 'lib/restfulness/path.rb', line 10 def initialize(route, string) self.route = route self.params = {} parse(string) end |
Instance Attribute Details
#components ⇒ Object
Returns the value of attribute components
8 9 10 |
# File 'lib/restfulness/path.rb', line 8 def components @components end |
#params ⇒ Object
Returns the value of attribute params
8 9 10 |
# File 'lib/restfulness/path.rb', line 8 def params @params end |
#route ⇒ Object
Returns the value of attribute route
8 9 10 |
# File 'lib/restfulness/path.rb', line 8 def route @route end |
Instance Method Details
#[](index) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/restfulness/path.rb', line 20 def [](index) if index.is_a?(Integer) components[index] else params[index] end end |
#to_s ⇒ Object
16 17 18 |
# File 'lib/restfulness/path.rb', line 16 def to_s '/' + components.join('/') end |