Class: Wrappi::PathGen
- Inherits:
-
Object
- Object
- Wrappi::PathGen
- Defined in:
- lib/wrappi/path_gen.rb
Defined Under Namespace
Classes: MissingParamError
Constant Summary collapse
- PATTERN =
/:\w+/
Instance Attribute Summary collapse
-
#input_params ⇒ Object
readonly
Returns the value of attribute input_params.
-
#input_path ⇒ Object
readonly
Returns the value of attribute input_path.
Instance Method Summary collapse
- #compiled_path ⇒ Object (also: #path)
-
#initialize(input_path, input_params) ⇒ PathGen
constructor
A new instance of PathGen.
- #processed_params ⇒ Object (also: #params)
Constructor Details
#initialize(input_path, input_params) ⇒ PathGen
Returns a new instance of PathGen.
6 7 8 9 10 |
# File 'lib/wrappi/path_gen.rb', line 6 def initialize(input_path, input_params) @input_path = input_path @input_params = Fusu::HashWithIndifferentAccess.new(input_params) @interpolable = input_path =~ PATTERN end |
Instance Attribute Details
#input_params ⇒ Object (readonly)
Returns the value of attribute input_params.
5 6 7 |
# File 'lib/wrappi/path_gen.rb', line 5 def input_params @input_params end |
#input_path ⇒ Object (readonly)
Returns the value of attribute input_path.
5 6 7 |
# File 'lib/wrappi/path_gen.rb', line 5 def input_path @input_path end |
Instance Method Details
#compiled_path ⇒ Object Also known as: path
12 13 14 15 |
# File 'lib/wrappi/path_gen.rb', line 12 def compiled_path return input_path unless interpolable? @compiled_path ||= URI.escape(new_sections.join('/')) end |
#processed_params ⇒ Object Also known as: params
18 19 20 21 |
# File 'lib/wrappi/path_gen.rb', line 18 def processed_params return input_params unless interpolable? @processed_params ||= input_params.reject{ |k, v| keys_in_params.include?(k.to_sym) } end |