Class: Foobara::CommandConnectors::ShCliConnector::InputsParser::Option::Flag

Inherits:
Option
  • Object
show all
Defined in:
foobara-sh-cli-connector-1.1.4/src/sh_cli_connector/inputs_parser/option/flag.rb

Direct Known Subclasses

OffFlag, OnFlag

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.applicable?(attribute_type) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'src/sh_cli_connector/inputs_parser/option/flag.rb', line 8

def applicable?(attribute_type)
  attribute_type.extends?(BuiltinTypes[:boolean])
end

.attribute_to_options(attribute_name, attribute_type:, prefix:, is_required:, default:, always_prefix_inputs:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'src/sh_cli_connector/inputs_parser/option/flag.rb', line 12

def attribute_to_options(
  attribute_name,
  attribute_type:,
  prefix:,
  is_required:,
  default:,
  always_prefix_inputs:
)
  klasses = []

  klasses << OnFlag if default != true
  klasses << OffFlag if default != false

  if klasses.size == 1
    klasses.first.new(
      attribute_name:,
      attribute_type:,
      is_required:,
      default:,
      prefix:,
      always_prefix_inputs:
    )
  else
    klasses.map do |klass|
      klass.new(
        attribute_name:,
        attribute_type:,
        is_required:,
        default:,
        prefix:,
        always_prefix_inputs:
      )
    end
  end
end

Instance Method Details

#_argument_text(_prefixed_name) ⇒ Object



49
50
51
# File 'src/sh_cli_connector/inputs_parser/option/flag.rb', line 49

def _argument_text(_prefixed_name)
  nil
end

#array?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'src/sh_cli_connector/inputs_parser/option/flag.rb', line 53

def array?
  false
end

#show_default?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'src/sh_cli_connector/inputs_parser/option/flag.rb', line 57

def show_default?
  false
end