Add the following code to your project's shard.yml under:
to use in production
- OR -
development_dependencies to use in development
A delimiter tree is a tree that is built from a string based on the delimiter. For example, if you have a string "foo;bar" then you will have a parent node "foo" and a child node "bar". Each node will hold a payload.
The delimiter tree also supports two special characters.
The tree will return an array of payloads for all matching * as well as the specific payload for the final matching string.
Add this to your application's
dependencies: delimiter_tree: github: drujensen/delimiter_tree
The delimiter tree is used to return a payload or an array of payloads for a particular delimited string. This can be used for url paths or any situation where you need to specifically hold data per each segment of a delimited string.
require "delimiter_tree" tree = Delimiter::Tree.new("/") tree.add "/*", :all_children tree.add "/products", :products tree.add "/products/:id", :specific_product result = tree.find "/products/2" puts result.payload # [:all_children, :products] puts result.params # :id => 2