Module: EISCP::Receiver::CommandMethods
- Included in:
- EISCP::Receiver
- Defined in:
- lib/eiscp/receiver/command_methods.rb
Overview
Iterates through every available command and defines a method to call that command. It’s intended to be used through Receiver and uses methods included by Receiver::Connection. Each method accepts a string that should match the human readable name of a valid value for that command.
Class Method Summary collapse
Class Method Details
.generate(&block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/eiscp/receiver/command_methods.rb', line 14 def self.generate(&block) Dictionary.zones.each do |zone| Dictionary.commands[zone].each do |command, _values| command_name = Dictionary.command_to_name(command).to_s.gsub(/-/, '_') define_method(command_name) do |v| instance_exec Parser.parse("#{command_name.gsub(/_/, '-')} #{v}"), &block end rescue StandardError => e puts e end end end |