Skip to content

Instantly share code, notes, and snippets.

@paractmol
Last active November 22, 2015 18:12
Show Gist options
  • Save paractmol/d96e4d88726b2128bddf to your computer and use it in GitHub Desktop.
Save paractmol/d96e4d88726b2128bddf to your computer and use it in GitHub Desktop.
class Collection
class Instance
def initialize(id)
@id = id
end
def say
"I am #{@id}"
end
end
def initialize(ary)
@ary = ary
end
def inspect
@ary
end
def [] id
raise "Array does not contain #{id}" unless @ary.include?(id)
Instance.new id
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment