Module: Zheng::Actions

Defined in:
lib/zheng/actions.rb,
lib/zheng/actions/game.rb,
lib/zheng/actions/player.rb,
lib/zheng/actions/database.rb

Defined Under Namespace

Modules: Database, Game, Player Classes: NoActionFound

Class Method Summary collapse

Class Method Details

.call(mod, action, *params) ⇒ Object



4
5
6
7
8
# File 'lib/zheng/actions.rb', line 4

def call(mod, action, *params)
  "Actions::#{mod.camelize}".constantize.send(action.to_sym, *params)
rescue NameError
  raise NoActionFound.new("#{mod} #{action} (#{$!})")
end

.script(text) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/zheng/actions.rb', line 10

def script text
  text.each_line do |l|
    begin
      call *Shellwords.shellwords(l) unless l.strip.empty? || l.strip[0,1] == '#'
    rescue
      Zheng::output("An error occured: #{$!}")
    end
  end
end