Class: Ukiryu::Models::ArgumentDefinition

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/ukiryu/models/argument_definition.rb

Overview

Argument definition for a command

Examples:

arg = ArgumentDefinition.new(
  name: 'input',
  type: 'file',
  variadic: true,
  position: 'last'
)

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object

Hash-like access for Type validation compatibility

Parameters:

  • key (Symbol, String)

    the attribute key

Returns:

  • (Object)

    the attribute value



94
95
96
97
98
99
100
# File 'lib/ukiryu/models/argument_definition.rb', line 94

def [](key)
  key_sym = key.to_sym
  # Return nil for unknown keys (like Type validation options)
  return nil unless respond_to?(key_sym, true)

  send(key_sym)
end

#last?Boolean

Check if this is the last argument

Returns:

  • (Boolean)

    true if position is :last



54
55
56
# File 'lib/ukiryu/models/argument_definition.rb', line 54

def last?
  position == 'last'
end

#name_symSymbol

Get name as symbol (cached for performance)

Returns:

  • (Symbol)

    the name as symbol



105
106
107
# File 'lib/ukiryu/models/argument_definition.rb', line 105

def name_sym
  @name_sym ||= name.to_sym
end

#numeric_positionInteger

Get numeric position for sorting

Returns:

  • (Integer)

    the numeric position



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ukiryu/models/argument_definition.rb', line 77

def numeric_position
  case position
  when 'last'
    999
  when 'first'
    1
  when /^\d+$/
    position.to_i
  else
    99
  end
end

#parsed_positionSymbol, Integer

Get the position as symbol or integer

Returns:

  • (Symbol, Integer)

    the parsed position



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ukiryu/models/argument_definition.rb', line 61

def parsed_position
  case position
  when 'last'
    :last
  when 'first'
    :first
  when /^\d+$/
    position.to_i
  else
    99
  end
end

#type_symSymbol

Get type as symbol (cached for performance)

Returns:

  • (Symbol)

    the type as symbol



112
113
114
# File 'lib/ukiryu/models/argument_definition.rb', line 112

def type_sym
  @type_sym ||= type.to_sym
end