Class: CommandMapper::Gen::Arg
- Inherits:
-
Object
- Object
- CommandMapper::Gen::Arg
- Defined in:
- lib/command_mapper/gen/arg.rb
Direct Known Subclasses
Instance Attribute Summary collapse
- #required ⇒ Boolean readonly
-
#type ⇒ Types::Type?
readonly
The value configuration for the argument.
Instance Method Summary collapse
-
#initialize(required: nil, type: nil) ⇒ Arg
constructor
Initializes the parsed argument.
-
#to_ruby ⇒ String
Converts the parsed argument to Ruby source code.
Constructor Details
#initialize(required: nil, type: nil) ⇒ Arg
Initializes the parsed argument.
20 21 22 23 |
# File 'lib/command_mapper/gen/arg.rb', line 20 def initialize(required: nil, type: nil) @required = required @type = type end |
Instance Attribute Details
#required ⇒ Boolean (readonly)
6 7 8 |
# File 'lib/command_mapper/gen/arg.rb', line 6 def required @required end |
#type ⇒ Types::Type? (readonly)
The value configuration for the argument.
11 12 13 |
# File 'lib/command_mapper/gen/arg.rb', line 11 def type @type end |
Instance Method Details
#to_ruby ⇒ String
Converts the parsed argument to Ruby source code.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/command_mapper/gen/arg.rb', line 30 def to_ruby ruby = [] ruby << "required: #{@required.inspect}" if @required == false if (@type && (type = @type.to_ruby)) ruby << "type: #{type}" end ruby.join(', ') end |