Class: Spoom::Sorbet::Translate::RBSCommentsToSorbetSigs::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs/options.rb

Constant Summary collapse

ALLOWED_OVERLOAD_STRATEGIES =
[:translate_all, :translate_last, :raise].freeze

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(overloads_strategy: :translate_all, erase_generic_types: false, output_format: HumanReadableRBIFormat.default, translate_abstract_methods: true) ⇒ Options

Returns a new instance of Options.

Signature:

  • (

  • ?overloads_strategy: Symbol,

  • ?erase_generic_types: bool,

  • ?output_format: BaseRBIFormat,

  • ?translate_abstract_methods: bool,

  • ) -> void



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs/options.rb', line 65

def initialize(
  overloads_strategy: :translate_all,
  erase_generic_types: false,
  output_format: HumanReadableRBIFormat.default,
  translate_abstract_methods: true
)
  unless ALLOWED_OVERLOAD_STRATEGIES.include?(overloads_strategy)
    raise ArgumentError, "Unknown overloads_strategy: #{overloads_strategy.inspect}. " \
      "Must be one of: #{ALLOWED_OVERLOAD_STRATEGIES.map(&:inspect).join(", ")}"
  end

  @overloads_strategy = overloads_strategy
  @erase_generic_types = erase_generic_types
  @rbi_options = RBI::RBS::MethodTypeTranslator::Options.new(erase_generic_types:) #: RBI::RBS::MethodTypeTranslator::Options
  @output_format = output_format
  @translate_abstract_methods = translate_abstract_methods

  freeze
end

Class Attribute Details

.defaultObject (readonly)

Signature:

  • Options



88
89
90
# File 'lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs/options.rb', line 88

def default
  @default
end

Instance Attribute Details

#erase_generic_typesObject (readonly)

Signature:

  • bool



48
49
50
# File 'lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs/options.rb', line 48

def erase_generic_types
  @erase_generic_types
end

#output_formatObject (readonly)

Signature:

  • BaseRBIFormat



54
55
56
# File 'lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs/options.rb', line 54

def output_format
  @output_format
end

#overloads_strategyObject (readonly)

Signature:

  • Symbol



43
44
45
# File 'lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs/options.rb', line 43

def overloads_strategy
  @overloads_strategy
end

#rbi_optionsObject (readonly)

Signature:

  • RBI::RBS::MethodTypeTranslator::Options



51
52
53
# File 'lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs/options.rb', line 51

def rbi_options
  @rbi_options
end

#translate_abstract_methodsObject (readonly)

Signature:

  • bool



57
58
59
# File 'lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs/options.rb', line 57

def translate_abstract_methods
  @translate_abstract_methods
end