class SPNet::CommandInPort

Provides a means to list and execute commands in a Block object.

@author James Tunnell

Constants

ARG_SPECS

Define arg specs to use in processing hashed arguments during initialize.

Public Class Methods

new(hashed_args) click to toggle source

A new instance of CommandInPort. @param [Hash] hashed_args Hashed arguments for initialization. See Network::ARG_SPECS

for details.
Calls superclass method SPNet::InPort::new
# File lib/spnet/ports/command_in_port.rb, line 18
def initialize hashed_args
  hash_make hashed_args, CommandInPort::ARG_SPECS
  super(:matching_class => CommandOutPort)
end

Public Instance Methods

exec_command(command, data) click to toggle source

Execute a command with the given data (nil by default).

# File lib/spnet/ports/command_in_port.rb, line 29
def exec_command command, data
  raise "Command #{command} not found in command list" unless @command_map.has_key?(command)
  @command_map[command].call data
end
list_commands() click to toggle source

List the commands that are available.

# File lib/spnet/ports/command_in_port.rb, line 24
def list_commands
  @command_map.keys
end