From: Dark Ambient Date: 2006-07-12T04:31:28+09:00 Subject: Re: blocks and procs ------=_Part_171309_18709012.1152646284218 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline hmmmm....i have that code in there: > def select( query ) > # parse query String > rules = Hash[*query.split(/\s*AND\s*/).map do |rule| > rule.split(/\s*=\s*/).map { |value| value.sub(/^['"](.+)['"]$/, > '\1') } end.flatten ] > > #match records > @records.select { |record| block_given? and yield record } > rules.all? { |field, value| record.send(field) == value } > > > end # end of method > > end # end of class On 7/11/06, James Edward Gray II wrote: > > On Jul 11, 2006, at 1:18 PM, Dark Ambient wrote: > > > I am running into some select errors though , via the select > > statement. > > Sure I see the trouble... > > > require "pp" > > db = ClientDB.new > > pp db.select { |record| record.client_name != "Gray Productions" } > > pp db.select { |record| record.client_name +~ /crew/i } > > pp db.select { |record| record.projects.size == 1 } > > pp db.select { |record| record.projects.include? "Ruby Quiz" } > > In order to run this example, you need to use the select() code in > the article, just a paragraph above it. I'm slowly making changes > and refining a solution as I go. > > Hope that helps. > > James Edward Gray II > > > ------=_Part_171309_18709012.1152646284218--