Subversion Info

Rev
437
Last Checked In
2008-03-28 00:49:20 (2 weeks ago)
Checked in by
deveiant

Parent

Included Modules

Class Index

Quicksearch

Arrow::Template::Container

The class which defines the behaviour of the ‘container’ template directive.

Constants

SVNRev
SVN Revision
SVNId
SVN Id
DelegatedMethods
The methods of collections which are delegated to their contents Array

Attributes

contents[RW]
The contents of the container
filters[R]
The Array of transform functions applied to this container at render time, in the order in which they will be applied.
name[R]
The name of the container
sortblock[R]
The sort block associated with the container.

Public Class Methods

new( name, *contents ) click to toggle source

Create a new Arrow::Template::Container object with the given name and contents.

    # File /Users/ged/source/ruby/Arrow/lib/arrow/template/container.rb, line 50
50:     def initialize( name, *contents )
51:         @name = name
52:         @contents = contents
53: 
54:         @sortblock = nil
55:         @filters = []
56: 
57:         super()
58:     end

Public Instance Methods

<<( object ) click to toggle source

Add the given object/s to this container.

    # File /Users/ged/source/ruby/Arrow/lib/arrow/template/container.rb, line 84
84:     def <<( object )
85:         @contents << object
86:         return self
87:     end
addFilter( &block ) click to toggle source

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.

    # File /Users/ged/source/ruby/Arrow/lib/arrow/template/container.rb, line 94
94:     def addFilter( &block )
95:         @filters << block
96:     end
each( &block ) click to toggle source

Iterate over the contents of this container after applying filters, sort blocks, etc. to them.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template/container.rb, line 109
109:     def each( &block )
110:         raise LocalJumpError, "no block given" unless block_given?
111: 
112:         contents = @contents.dup
113:         contents.sort!( &@sortblock ) if @sortblock
114:         @filters.each {|filter|
115:             contents = contents.collect( &filter )
116:         }
117: 
118:         Arrow::Template::Iterator.new( *contents ).each( &block )
119:     end
last() click to toggle source

Return the last value to be set in this container

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template/container.rb, line 123
123:     def last
124:         @contents.last
125:     end
setSort( &block ) click to toggle source

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.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/template/container.rb, line 102
102:     def setSort( &block )
103:         @sortblock = block
104:     end

secsequence

--- SEC00131

seccomment

--- ""

attributes

--- 
- name: contents
  rw: RW
  a_desc: |+
    
    The contents of the container
    
- name: filters
  rw: R
  a_desc: |+
    
    The Array of transform functions applied to this container at render time,
    in the order in which they will be applied.
    
- name: name
  rw: R
  a_desc: |+
    
    The name of the container
    
- name: sortblock
  rw: R
  a_desc: |+
    
    The sort block associated with the container.
    

method_list

--- 
- methods: 
  - visibility: public
    aref: M000143
    name: new
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template/container.rb, line 50</span>\n\
      50:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">initialize</span>( <span class=\"ruby-identifier\">name</span>, <span class=\"ruby-operator\">*</span><span class=\"ruby-identifier\">contents</span> )\n\
      51:         <span class=\"ruby-ivar\">@name</span> = <span class=\"ruby-identifier\">name</span>\n\
      52:         <span class=\"ruby-ivar\">@contents</span> = <span class=\"ruby-identifier\">contents</span>\n\
      53: \n\
      54:         <span class=\"ruby-ivar\">@sortblock</span> = <span class=\"ruby-keyword kw\">nil</span>\n\
      55:         <span class=\"ruby-ivar\">@filters</span> = []\n\
      56: \n\
      57:         <span class=\"ruby-keyword kw\">super</span>()\n\
      58:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Create a <a href="Container.html#M000143">new</a> <a
      href="Container.html">Arrow::Template::Container</a> object with the given
      <tt>name</tt> and <tt>contents</tt>.
      </p>
    params: ( name, *contents )
  category: Class
  type: Public
- methods: 
  - visibility: public
    aref: M000144
    name: "&lt;&lt;"
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template/container.rb, line 84</span>\n\
      84:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-operator\">&lt;&lt;</span>( <span class=\"ruby-identifier\">object</span> )\n\
      85:         <span class=\"ruby-ivar\">@contents</span> <span class=\"ruby-operator\">&lt;&lt;</span> <span class=\"ruby-identifier\">object</span>\n\
      86:         <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">self</span>\n\
      87:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Add the given object/s to this container.
      </p>
    params: ( object )
  - visibility: public
    aref: M000145
    name: addFilter
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template/container.rb, line 94</span>\n\
      94:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">addFilter</span>( <span class=\"ruby-operator\">&amp;</span><span class=\"ruby-identifier\">block</span> )\n\
      95:         <span class=\"ruby-ivar\">@filters</span> <span class=\"ruby-operator\">&lt;&lt;</span> <span class=\"ruby-identifier\">block</span>\n\
      96:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Add the specified filter <tt>block</tt> to the container. When the
      container is used in a render, the filter block will be called once for <a
      href="Container.html#M000147">each</a> contained object and whatever it
      returns will be used instead of the original.
      </p>
    params: ( &amp;block )
  - visibility: public
    aref: M000147
    name: each
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template/container.rb, line 109</span>\n\
      109:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">each</span>( <span class=\"ruby-operator\">&amp;</span><span class=\"ruby-identifier\">block</span> )\n\
      110:         <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">LocalJumpError</span>, <span class=\"ruby-value str\">&quot;no block given&quot;</span> <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-identifier\">block_given?</span>\n\
      111: \n\
      112:         <span class=\"ruby-identifier\">contents</span> = <span class=\"ruby-ivar\">@contents</span>.<span class=\"ruby-identifier\">dup</span>\n\
      113:         <span class=\"ruby-identifier\">contents</span>.<span class=\"ruby-identifier\">sort!</span>( <span class=\"ruby-operator\">&amp;</span><span class=\"ruby-ivar\">@sortblock</span> ) <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-ivar\">@sortblock</span>\n\
      114:         <span class=\"ruby-ivar\">@filters</span>.<span class=\"ruby-identifier\">each</span> {<span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">filter</span><span class=\"ruby-operator\">|</span>\n\
      115:             <span class=\"ruby-identifier\">contents</span> = <span class=\"ruby-identifier\">contents</span>.<span class=\"ruby-identifier\">collect</span>( <span class=\"ruby-operator\">&amp;</span><span class=\"ruby-identifier\">filter</span> )\n\
      116:         }\n\
      117: \n\
      118:         <span class=\"ruby-constant\">Arrow</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Template</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Iterator</span>.<span class=\"ruby-identifier\">new</span>( <span class=\"ruby-operator\">*</span><span class=\"ruby-identifier\">contents</span> ).<span class=\"ruby-identifier\">each</span>( <span class=\"ruby-operator\">&amp;</span><span class=\"ruby-identifier\">block</span> )\n\
      119:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Iterate over the contents of this container after applying filters, sort
      blocks, etc. to them.
      </p>
    params: ( &amp;block )
  - visibility: public
    aref: M000148
    name: last
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template/container.rb, line 123</span>\n\
      123:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">last</span>\n\
      124:         <span class=\"ruby-ivar\">@contents</span>.<span class=\"ruby-identifier\">last</span>\n\
      125:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Return the <a href="Container.html#M000148">last</a> value to be set in
      this container
      </p>
    params: ()
  - visibility: public
    aref: M000146
    name: setSort
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/template/container.rb, line 102</span>\n\
      102:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">setSort</span>( <span class=\"ruby-operator\">&amp;</span><span class=\"ruby-identifier\">block</span> )\n\
      103:         <span class=\"ruby-ivar\">@sortblock</span> = <span class=\"ruby-identifier\">block</span>\n\
      104:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Add the specified sort <tt>block</tt> to the container. When the container
      is used in a render, its contents will be used in the order returned from
      the sort block.
      </p>
    params: ( &amp;block )
  category: Instance
  type: Public

sectitle

--- 

constants

--- 
- name: SVNRev
  desc: |+
    
    SVN Revision
    
  value: "%q$Rev: 437 $"
- name: SVNId
  desc: |+
    
    SVN Id
    
  value: "%q$Id: container.rb 437 2008-03-28 00:49:20Z deveiant $"
- name: DelegatedMethods
  desc: |+
    
    The methods of collections which are delegated to their contents Array
    
  value: ( (Array.instance_methods(false) | Enumerable.instance_methods(false)) -           %w{&lt;&lt;} )

[Validate]

Generated with the Darkfish Rdoc Generator.