Class: HashMapper::PathMap
- Inherits:
-
Object
- Object
- HashMapper::PathMap
- Includes:
- Enumerable
- Defined in:
- lib/hash_mapper.rb
Overview
contains array of path segments
Instance Attribute Summary collapse
-
#filter ⇒ Object
writeonly
Sets the attribute filter.
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
Instance Method Summary collapse
- #apply_filter(value) ⇒ Object
- #each(&blk) ⇒ Object
-
#initialize(path) ⇒ PathMap
constructor
A new instance of PathMap.
- #last ⇒ Object
Constructor Details
#initialize(path) ⇒ PathMap
Returns a new instance of PathMap.
124 125 126 127 128 |
# File 'lib/hash_mapper.rb', line 124 def initialize(path) @path = path.dup @segments = parse(path) @filter = lambda{|value| value}# default filter does nothing end |
Instance Attribute Details
#filter=(value) ⇒ Object (writeonly)
Sets the attribute filter
122 123 124 |
# File 'lib/hash_mapper.rb', line 122 def filter=(value) @filter = value end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
121 122 123 |
# File 'lib/hash_mapper.rb', line 121 def segments @segments end |
Instance Method Details
#apply_filter(value) ⇒ Object
130 131 132 |
# File 'lib/hash_mapper.rb', line 130 def apply_filter(value) @filter.call(value) end |
#each(&blk) ⇒ Object
134 135 136 |
# File 'lib/hash_mapper.rb', line 134 def each(&blk) @segments.each(&blk) end |
#last ⇒ Object
138 139 140 |
# File 'lib/hash_mapper.rb', line 138 def last @segments.last end |