This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ActsAsCsv | |
| def self.included(base) | |
| base.extend ClassMethods | |
| end | |
| module ClassMethods | |
| def acts_as_csv | |
| include InstanceMethods | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |