class Rhea::CommandType

Attributes

format[RW]
key[RW]
name[RW]

Public Class Methods

all() click to toggle source
# File lib/rhea/command_type.rb, line 19
def self.all
  @all ||= Rhea.configuration.command_types.map do |attributes|
    new(attributes)
  end
end
find(key) click to toggle source
# File lib/rhea/command_type.rb, line 25
def self.find(key)
  command_type = all.find { |command_type| command_type.key == key }
  raise "Invalid key: #{key}" unless command_type
  command_type
end
new(key:, name:, format:) click to toggle source
# File lib/rhea/command_type.rb, line 5
def initialize(key:, name:, format:)
  self.key = key
  self.name = name
  self.format = format
end
options_for_select() click to toggle source
# File lib/rhea/command_type.rb, line 31
def self.options_for_select
  all.map do |command_type|
    [command_type.name, command_type.key, :'data-syntax' => command_type.displayed_format]
  end
end

Public Instance Methods

displayed_format() click to toggle source
# File lib/rhea/command_type.rb, line 15
def displayed_format
  format.gsub('$INPUT', '$input')
end
input_to_command_expression(input) click to toggle source
# File lib/rhea/command_type.rb, line 11
def input_to_command_expression(input)
  format.gsub('$INPUT', input)
end