The class which defines the behaviour of the ‘container’ template directive.
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
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
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
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
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
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
--- SEC00131
--- ""
--- - 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.
--- - 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: "<<" 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\"><<</span>( <span class=\"ruby-identifier\">object</span> )\n\ 85: <span class=\"ruby-ivar\">@contents</span> <span class=\"ruby-operator\"><<</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\">&</span><span class=\"ruby-identifier\">block</span> )\n\ 95: <span class=\"ruby-ivar\">@filters</span> <span class=\"ruby-operator\"><<</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: ( &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\">&</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\">"no block given"</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\">&</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\">&</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\">&</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: ( &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\">&</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: ( &block ) category: Instance type: Public
---
--- - 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{<<} )
Generated with the Darkfish Rdoc Generator.