Class: Arrow::Template::Container
- Inherits:
 - 
      Arrow::Object
      
        
- Object
 - Arrow::Object
 - Arrow::Template::Container
 
 - Extends:
 - Forwardable
 - Includes:
 - Enumerable
 - Defined in:
 - lib/arrow/template/container.rb
 
Overview
The Arrow::Template::Container class, a derivative of Arrow::Object. Instances of this class are stateful containers for ContainerDirective nodes .
Authors
Michael Granger
Please see the file LICENSE in the top-level directory for licensing details.
Constant Summary
- SVNRev =
          
SVN Revision
 %q$Rev$- SVNId =
          
SVN Id
 %q$Id$- DelegatedMethods =
          
The methods of collections which are delegated to their contents Array
 ( (Array.instance_methods(false) | Enumerable.instance_methods(false)) - %w{<<} )
Instance Attribute Summary
- 
  
    
      - (Object) contents 
    
    
  
  
  
    
    
  
  
  
  
  
    
The contents of the container.
 - 
  
    
      - (Object) filters 
    
    
  
  
  
    readonly
    
  
  
  
  
  
    
The Array of transform functions applied to this container at render time, in the order in which they will be applied.
 - 
  
    
      - (Object) name 
    
    
  
  
  
    readonly
    
  
  
  
  
  
    
The name of the container.
 - 
  
    
      - (Object) sortblock 
    
    
  
  
  
    readonly
    
  
  
  
  
  
    
The sort block associated with the container.
 
Instance Method Summary
- 
  
    
      - (Object) <<(object) 
    
    
  
  
  
  
  
  
  
    
Add the given object/s to this container.
 - 
  
    
      - (Object) addFilter(&block) 
    
    
  
  
  
  
  
  
  
    
Add the specified filter block to the container.
 - 
  
    
      - (Object) each(&block) 
    
    
  
  
  
  
  
  
  
    
Iterate over the contents of this container after applying filters, sort blocks, etc.
 - 
  
    
      - (Container) initialize(name, *contents) 
    
    
  
  
    constructor
  
  
  
  
  
  
    
Create a new Arrow::Template::Container object with the given name and contents.
 - 
  
    
      - (Object) last 
    
    
  
  
  
  
  
  
  
    
Return the last value to be set in this container.
 - 
  
    
      - (Object) setSort(&block) 
    
    
  
  
  
  
  
  
  
    
Add the specified sort block to the container.
 
Methods inherited from Arrow::Object
deprecate_class_method, deprecate_method, inherited
Methods included from Arrow::Loggable
Constructor Details
- (Container) initialize(name, *contents)
Create a new Arrow::Template::Container object with the given name and contents.
      39 40 41 42 43 44 45 46 47  | 
    
      # File 'lib/arrow/template/container.rb', line 39 def initialize( name, *contents ) @name = name @contents = contents @sortblock = nil @filters = [] super() end  | 
  
Instance Attribute Details
- (Object) contents
The contents of the container
      59 60 61  | 
    
      # File 'lib/arrow/template/container.rb', line 59 def contents @contents end  | 
  
- (Object) filters (readonly)
The Array of transform functions applied to this container at render time, in the order in which they will be applied.
      66 67 68  | 
    
      # File 'lib/arrow/template/container.rb', line 66 def filters @filters end  | 
  
- (Object) name (readonly)
The name of the container
      62 63 64  | 
    
      # File 'lib/arrow/template/container.rb', line 62 def name @name end  | 
  
- (Object) sortblock (readonly)
The sort block associated with the container.
      69 70 71  | 
    
      # File 'lib/arrow/template/container.rb', line 69 def sortblock @sortblock end  | 
  
Instance Method Details
- (Object) <<(object)
Add the given object/s to this container.
      73 74 75 76  | 
    
      # File 'lib/arrow/template/container.rb', line 73 def <<( object ) @contents << object return self end  | 
  
- (Object) addFilter(&block)
Add the specified filter block to the container. When the container is used in a render, the filter block will be called once for each contained object and whatever it returns will be used instead of the original.
      83 84 85  | 
    
      # File 'lib/arrow/template/container.rb', line 83 def addFilter( &block ) @filters << block end  | 
  
- (Object) each(&block)
Iterate over the contents of this container after applying filters, sort blocks, etc. to them.
      98 99 100 101 102 103 104 105 106 107 108  | 
    
      # File 'lib/arrow/template/container.rb', line 98 def each( &block ) raise LocalJumpError, "no block given" unless block_given? contents = @contents.dup contents.sort!( &@sortblock ) if @sortblock @filters.each {|filter| contents = contents.collect( &filter ) } Arrow::Template::Iterator.new( *contents ).each( &block ) end  | 
  
- (Object) last
Return the last value to be set in this container
      112 113 114  | 
    
      # File 'lib/arrow/template/container.rb', line 112 def last @contents.last end  | 
  
- (Object) setSort(&block)
Add the specified sort block to the container. When the container is used in a render, its contents will be used in the order returned from the sort block.
      91 92 93  | 
    
      # File 'lib/arrow/template/container.rb', line 91 def setSort( &block ) @sortblock = block end  |