Last active
October 1, 2015 05:02
-
-
Save kangkyu/67b8ed03fbaa67d87659 to your computer and use it in GitHub Desktop.
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 Sample | |
def initialize(hsh) | |
@hsh = hsh | |
end | |
def method_missing(method) | |
key = @hsh.has_key?(method) ? method : method.to_s | |
@hsh[key] | |
end | |
end | |
h = {"this" => [1,2,3,4,5,6], "that" => ['here', 'there', 'everywhere'], :other => 'here'} | |
c = Sample.new(h) | |
p c.this | |
p c.that | |
p c.other |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment