a = {}
a["test"] = [] if a["test"].nil?
a["test"] << 5

Ruby Fill Array or create it

by Fu86, May 24, 2011 05:07, 3 refactorings, tagged with ruby, hash, array

How can I write this in a c...

Ee0505bbd355292778077fb662c88f13 Talk
f = { "user" => { "name" => "Tom", "message" => { "count" => 24, "last" => "2011-02-05" } } }
q = "user/message/last"
v = q.split("/")
...

Ruby Finding a value in a Hash b...

by Xeph, May 02, 2011 06:28, 2 refactorings, tagged with enumerable, hash

I've got a hash with nested...

F92de739cd61d6f3f4b71e5d07634a2e Talk
openid_mapping = {
  :email => ["email", "http://axschema.org/contact/email"], 
  :name => ["fullname", "http://axschema.org/namePerson"]
...

Ruby Hash + Array refactor

by Oriol, August 19, 2010 17:56, 29 refactorings, tagged with ruby, hash, array, openid, sreg, axschema

This actually works but I w...

E4679be8d7d2484f9c0b8c4df71f4d2a Talk
# Initial attributes Hash
# 
attributes = {
...

Ruby Ruby Hash Extraction Using ...

by notbrain.myopenid.com, February 24, 2010 23:13, 8 refactorings, tagged with rails, ruby, regex, hash, block

I'm looking for a better wa...

55502f40dc8b7c769880b10874abc9d0 Talk
pages.keys.each do |k|

      logger.debug "Pages for #{k} channel:"
...

Ruby Can this be less clunky?

by bruno antunes, November 26, 2009 15:40, 4 refactorings, tagged with ruby, hash, find_all

"pages" is a Hash and conta...

1b491994d6011d720e332af6e1ffd03b Talk
so whats so magical about this Hash?
...

Ruby Magical Hash

by michal.hantl.myopenid.com, October 08, 2009 07:32, 8 refactorings, tagged with ruby, hash, nested hash

Yesterday i wrote this neat...

C2a5bc0633a2eef9274744bd273063a4 Talk
def get_roles()
    roles = []
    store = {}
...

Ruby Loop through Activerecord r...

by jeremypeterson.myopenid.com, September 30, 2009 13:40, 1 refactoring, tagged with rails, hash, total values

I have a Contributor and Pr...

55502f40dc8b7c769880b10874abc9d0 Talk
# call-seq:
  #   StatisticsUtils.merge_sum(hash1, hash2, ...) -> merged_hash
  #
...

Ruby Total the values in multipl...

by Trejkaz, July 08, 2009 00:54, 2 refactorings, tagged with short, hash, sum, merge

This is obviously not very ...

42b570f6f4312a872c2fc671e3ddc82b Talk
require 'hpricot'

class Parser
...

Ruby Create a Hash from XML usin...

by smacks, June 25, 2009 12:23, 1 refactoring, tagged with ruby, xml, hash, hpricot, soap

With ruby you could use REX...

34d2ae3f7fdcec853ec24cf85715da96 Talk
s = "The green hat is the twin of the green hat"
h = Hash.new(0)
s.split.each do |w|
...

Ruby Count words in a string

by andyjeffries, May 02, 2009 13:41, 16 refactorings, tagged with hash, string strip, simple

This is a coding question I...

5cb7a05b6de4a6655319db9333be429c Talk
class String
  def dasherize
...

Ruby Hash#switchify

by Tj Holowaychuk, April 08, 2009 21:26, 3 refactorings, tagged with ruby, hash, switch

Whipped this up really quic...

F1e3ab214a976a39cfd713bc93deb10f Talk
class Array
  def to_h
    hash = {}
...

Ruby Conversion from the 2d arra...

by Dmitry Polushkin, October 22, 2008 09:11, 7 refactorings, tagged with convert, hash, 2d array

Conversion from the 2d arra...

832ed6ace46d61032151f4e1864c057f Talk
def translation_links
    lang = [
      %w[en english us], 
...

Ruby nested array to set of html...

by seaofclouds, October 09, 2008 07:51, 2 refactorings, tagged with ruby, hash, array, translation

i have a simple array that ...

F55e8e113669f6ea7d1d99f38907ce54 Talk
FIELDS = [ 'first', 'last',      'band' ]
DATA   = [['Kurt',  'Cobain',    'Nirvana'],
          ['Jimi',  'Page',      'Led Zeppelin'],
...

Ruby Map fields array and data a...

by charlesroper, September 22, 2008 15:23, 9 refactorings, tagged with hash, array

First posting here. I just ...

93fc84c261cdce2e2f1d64c8e531ecb7 Talk
pools = {1 => [1,2,3], 2=> [3,4,5], 3=> [5,6,7]}
intersection = []
pools.each do |k,v|
...

Ruby Find the Intersection of Ar...

by AviFlombaum, July 31, 2008 21:28, 13 refactorings, tagged with hash, arrays, intersection

Find the intersection of ar...

Fafb062f6e8c394dd6b0689c13db2b88 Talk
times.each do |time|
      events.each do |event|
        if time.strftime("%I:%M %p") == event.datetime.strftime("%I:%M %p")
...

Ruby two for loops cleanup?

by ttdavett.myopenid.com, July 31, 2008 00:11, 7 refactorings, tagged with rails, ruby, hash, array

times is an array of dateti...

F677fa685a2cfe8aff31f161062db3d3 Talk
module Keys_to_Meths
  def method_missing(meth, *args)
    if meth.to_s[-1] == 61 #if last char is an equal sign
...

Ruby Hash.keys_to_attr

by Ryguy, June 12, 2008 04:05, 3 refactorings, tagged with hash, methods

/no comment/

>_>

Ba665f86f90a1982af7b9c857418fcdb Talk
require 'net/http'
require 'rubygems'
require 'xmlsimple'
...

Ruby Parsing XML from a Web Service

by mwilliams, May 17, 2008 21:10, 3 refactorings, tagged with ruby, xml, hash, web, service

I'm working with a web serv...

4236ea6b84f4899b469e8edff4bf6d22 Talk
require 'erb'

# GOAL: render the template with the following vars
...

Ruby Given a hash of variables, ...

by mislav, April 12, 2008 15:12, 6 refactorings, tagged with hash, metaprogramming, erb, singleton, metaclass, render

This works. Now, is there a...

8f93a872e399bc1353cc8d4e791d5401 Talk
class Hash
  def fetch_all(key)
    results = []
...

Ruby Recursive Hash#fetch

by Neo, March 12, 2008 14:05, 3 refactorings, tagged with hash, nested hash, fetch

I wanted a Hash#fetch that ...

E64b3f6a4b0bde29f654eca45fcbb20f Talk
<table class="charge">
  <tr>
    <td colspan="100%" class="mainHeader"><%=@label.label%></td>
...

Ruby Iterating through a nested ...

by mwilliams, January 31, 2008 18:21, 3 refactorings, tagged with rails, ruby, Ruby on Rails, view, table, hash, nested hash, iterator, iterate

Good afternoon. I have a n...

4236ea6b84f4899b469e8edff4bf6d22 Talk