class Fuelcell::Action::ArgDefinition

Constants

NO_DEFAULT_ASSIGNED

Attributes

banner[R]
default[R]
name[R]
required[R]
required?[R]
type[R]

Public Class Methods

new(text, config = {}) click to toggle source
# File lib/fuelcell/action/arg_definition.rb, line 9
def initialize(text, config = {})
  @name     = text.to_s
  @required = config[:required] == true ? true : false
  @type     = validate_type(config[:type])
  @default  = config.fetch(:default) { NO_DEFAULT_ASSIGNED }
  @banner   = config[:banner] || ''
end

Public Instance Methods

default?() click to toggle source
# File lib/fuelcell/action/arg_definition.rb, line 17
def default?
  @default == NO_DEFAULT_ASSIGNED ? false : true
end

Private Instance Methods

validate_type(value) click to toggle source
# File lib/fuelcell/action/arg_definition.rb, line 23
def validate_type(value)
  case value.to_s.to_sym
  when :string, :text, :"" then :string
  when :number, :numeric   then :numeric
  when :boolean, :bool     then :bool
  when :hash               then :hash
  when :array              then :array
  else
    fail ArgumentError, "invalid type #{value}"
  end
end