class Command
Attributes
arguments[RW]
commandline[RW]
execution_date[RW]
name[RW]
user[RW]
Public Class Methods
build(command, *args)
click to toggle source
# File lib/bidding/command.rb, line 22 def self.build(command, *args) args.select {|arg| arg.to_s }.insert(0, command).join " " end
camel_case(s)
click to toggle source
# File lib/bidding/command.rb, line 26 def self.camel_case(s) return s if s !~ /_/ && s =~ /[A-Z]+.*/ s.split('_').map{|e| e.capitalize}.join end
parameters(*args)
click to toggle source
# File lib/bidding/command.rb, line 4 def self.parameters(*args) args.each do |arg| self.class_eval("def #{arg};arguments["+args.index(arg).to_s+"];end") end end
parse(commandline, user, time)
click to toggle source
# File lib/bidding/command.rb, line 10 def self.parse(commandline, user, time) parts = commandline.split(" ") name = camel_case parts.shift command = Kernel.const_get(name).new command.name = name command.user = user command.arguments = parts command.execution_date = time command.commandline = commandline command end
Public Instance Methods
execute()
click to toggle source
# File lib/bidding/command.rb, line 32 def execute raise 'execute method not implemented for class: ' + self.class.name end
replay()
click to toggle source
# File lib/bidding/command.rb, line 36 def replay @replay = true execute end