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...
I've got a hash with nested...
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...
# 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...
pages.keys.each do |k|
logger.debug "Pages for #{k} channel:"
...
Ruby Can this be less clunky?
"pages" is a Hash and conta...
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...
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...
# call-seq: # StatisticsUtils.merge_sum(hash1, hash2, ...) -> merged_hash # ...
Ruby Total the values in multipl...
This is obviously not very ...
require 'hpricot' class Parser ...
Ruby Create a Hash from XML usin...
With ruby you could use REX...
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
This is a coding question I...
class Array
def to_h
hash = {}
...
Ruby Conversion from the 2d arra...
Conversion from the 2d arra...
def translation_links
lang = [
%w[en english us],
...
Ruby nested array to set of html...
i have a simple array that ...
FIELDS = [ 'first', 'last', 'band' ]
DATA = [['Kurt', 'Cobain', 'Nirvana'],
['Jimi', 'Page', 'Led Zeppelin'],
...
Ruby Map fields array and data a...
First posting here. I just ...
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...
Find the intersection of ar...
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?
times is an array of dateti...
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
/no comment/
>_>
require 'net/http' require 'rubygems' require 'xmlsimple' ...
Ruby Parsing XML from a Web Service
I'm working with a web serv...
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...
class Hash
def fetch_all(key)
results = []
...
Ruby Recursive Hash#fetch
I wanted a Hash#fetch that ...
<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...
How can I write this in a c...