Skip to content

Instantly share code, notes, and snippets.

View macosgrove's full-sized avatar

Mary-Anne Cosgrove macosgrove

View GitHub Profile
@macosgrove
macosgrove / ruby_2.rb
Created November 6, 2011 12:25
7L7W Ruby Day 2
class Tree
attr_accessor :children, :node_name
# @param hsh [Hash]
def initialize(hsh)
unless hsh.empty?
@children=[]
@node_name = hsh.keys.first
hsh[@node_name].each_pair { |k,v| @children.push(Tree.new(k=>v)) }
end
@macosgrove
macosgrove / ruby_3.rb
Created November 7, 2011 23:16
7L7W Ruby Day 3
module ActsAsCsv
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_csv
include InstanceMethods
end
end