Sha256: b3b19cf4c4456cdc68851cedf895aa3bcb940cb0df69a1e010df1d67fb6ffb69
Contents?: true
Size: 879 Bytes
Versions: 3
Compression:
Stored size: 879 Bytes
Contents
# frozen_string_literal: true require "open3" require "io/wait" module Textbringer Command = Struct.new(:name, :block, :doc) module Commands include Utils @command_table = {} def self.list @command_table.keys end def self.command_table @command_table end def self.[](name) @command_table[name.intern] end def define_command(name, doc: "No documentation", &block) name = name.intern Commands.send(:define_method, name, &block) Commands.command_table[name] = Command.new(name, block, doc) name end module_function :define_command def undefine_command(name) name = name.intern if Commands.command_table.key?(name) Commands.send(:undef_method, name) Commands.command_table.delete(name) end end module_function :undefine_command end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
textbringer-0.2.1 | lib/textbringer/commands.rb |
textbringer-0.2.0 | lib/textbringer/commands.rb |
textbringer-0.1.9 | lib/textbringer/commands.rb |