Created
February 12, 2010 17:11
-
-
Save ljsc/302762 to your computer and use it in GitHub Desktop.
This file contains 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
require 'pp' | |
class Foo | |
def parameterfest(one, two, subopts, opts) | |
puts "One: #{one}" | |
puts "Two: #{two}" | |
puts "Subopts: #{subopts.pretty_print_inspect}" | |
puts "Opts: #{opts.pretty_print_inspect}" | |
end | |
end | |
class PFestParameters | |
def initialize | |
yield self | |
end | |
def one(o) | |
@one = o | |
end | |
def two(t) | |
@two = t | |
end | |
def sub(opts) | |
@sub = opts | |
end | |
def opts(opts) | |
@opts = opts | |
end | |
def to_a | |
[@one, @two, @sub, @opts] | |
end | |
end | |
params = PFestParameters.new do |p| | |
p.one "1" | |
p.two "2" | |
p.sub :a => 'A', :b => 'B' | |
p.opts :z => 'Z' | |
end | |
foo = Foo.new | |
foo.parameterfest(*params) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment