Skip to content

Instantly share code, notes, and snippets.

@metacritical
Created February 9, 2012 21:46
Show Gist options
  • Save metacritical/1783500 to your computer and use it in GitHub Desktop.
Save metacritical/1783500 to your computer and use it in GitHub Desktop.
Lets judge Which is better...
class Carpark
def initialize(arguments)
@program_mode = {true => Interactive,false => Filemode}[arguments].new
end
end
arg_params = ARGV.empty?
carpark = Carpark.new(arg_params)
V.S (versus)
class Carpark
def initialize(mode)
@mode = mode
end
end
class CommandLineParser
def initialize(arguments)
@arguments = arguments
end
def build_input_mode
arguments.empty? ? Interactive.new : Filemode.new
end
end
Carpark.new(CommandLineParser.new(ARGV).build_input_mode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment