module Drudge::ClassDSL
A DSL that allows writing of a command line tool (kit) as a class
Public Class Methods
included(cls)
click to toggle source
# File lib/drudge/class_dsl.rb, line 12 def self.included(cls) cls.singleton_class.send :include, ClassMethods end
Public Instance Methods
to_kit(name = $0)
click to toggle source
converts this into a (command) kit,
# File lib/drudge/class_dsl.rb, line 17 def to_kit(name = $0) Kit.new name, build_commands(self.class.__commands) end
Private Instance Methods
build_commands(commands)
click to toggle source
# File lib/drudge/class_dsl.rb, line 23 def build_commands(commands) commands.map do |c| Command.new(c[:name], c[:params], -> (*args) { self.send c[:name], *args }, **c[:meta]) end end