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
- #first ⇒ Object
- 
  
    
      #initialize(path)  ⇒ PathMap 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of PathMap. 
- #last ⇒ Object
- #size ⇒ Object
Methods included from Enumerable
Constructor Details
#initialize(path) ⇒ PathMap
Returns a new instance of PathMap.
| 167 168 169 170 171 | # File 'lib/hash_mapper.rb', line 167 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
| 165 166 167 | # File 'lib/hash_mapper.rb', line 165 def filter=(value) @filter = value end | 
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
| 164 165 166 | # File 'lib/hash_mapper.rb', line 164 def segments @segments end | 
Instance Method Details
#apply_filter(value) ⇒ Object
| 173 174 175 | # File 'lib/hash_mapper.rb', line 173 def apply_filter(value) @filter.call(value) end | 
#each(&blk) ⇒ Object
| 177 178 179 | # File 'lib/hash_mapper.rb', line 177 def each(&blk) @segments.each(&blk) end | 
#first ⇒ Object
| 181 182 183 | # File 'lib/hash_mapper.rb', line 181 def first @segments.first end | 
#last ⇒ Object
| 185 186 187 | # File 'lib/hash_mapper.rb', line 185 def last @segments.last end | 
#size ⇒ Object
| 189 190 191 | # File 'lib/hash_mapper.rb', line 189 def size @segments.size end |