A
Ara.T.Howard
URLS:
http://raa.ruby-lang.org/project/arrayfields/
http://www.codeforpeople.com/lib/ruby/arrayfields/
SYNOPSIS
allow keyword access to arrays:
require 'arrayfields'
fields = 'name', 'age'
row = [ 'bob', 30 ]
row.fields = fields
row[ 'name' ] #=> 'bob'
row.indices 'name', 'age' #=> [ 'bob', 30 ]
assigning to un-named fields appends:
stack = []
stack.fields = %w(zero one)
stack['zero'] = 'zero'
stack['one'] = 'one'
stack #=> [ 'zero', 'one' ]
*very* useful for database work
relation = pgconn.query sql
relation.size #=> 65536
# yikes! do we really want to re-construct a hash for for each tuple when
# we already have Arrays?
fields = %w(ssn name position)
table.each{|tuple| tuple.fields = fields}
table[34578]['ssn'] #=> 574865032
LIST OF OVERRIDDEN METHODS
Array#[]
Array#[]=
Array#at
Array#delete_at
Array#fill
Array#values_at
Array#indices
Array#indexes
Array#slice
Array#slice!
LIST OF NEW Array METHODS
Array#fields=
Array#each_with_field
DOCS/USAGE/SAMPLE
lib/arrayfields.rb
test/arrayfields.rb
AUTHOR
(e-mail address removed)
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================
http://raa.ruby-lang.org/project/arrayfields/
http://www.codeforpeople.com/lib/ruby/arrayfields/
SYNOPSIS
allow keyword access to arrays:
require 'arrayfields'
fields = 'name', 'age'
row = [ 'bob', 30 ]
row.fields = fields
row[ 'name' ] #=> 'bob'
row.indices 'name', 'age' #=> [ 'bob', 30 ]
assigning to un-named fields appends:
stack = []
stack.fields = %w(zero one)
stack['zero'] = 'zero'
stack['one'] = 'one'
stack #=> [ 'zero', 'one' ]
*very* useful for database work
relation = pgconn.query sql
relation.size #=> 65536
# yikes! do we really want to re-construct a hash for for each tuple when
# we already have Arrays?
fields = %w(ssn name position)
table.each{|tuple| tuple.fields = fields}
table[34578]['ssn'] #=> 574865032
LIST OF OVERRIDDEN METHODS
Array#[]
Array#[]=
Array#at
Array#delete_at
Array#fill
Array#values_at
Array#indices
Array#indexes
Array#slice
Array#slice!
LIST OF NEW Array METHODS
Array#fields=
Array#each_with_field
DOCS/USAGE/SAMPLE
lib/arrayfields.rb
test/arrayfields.rb
AUTHOR
(e-mail address removed)
-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================