lib/parlour/rbs_generator/parameter.rb
# A string of how this parameter should be defined in an RBS signature.
#
# @return [String]
A string of how this parameter should be defined in an RBS signature.
A string of how this parameter should be defined in an RBS signature .
def to_rbs_param
        raise 'blocks are not parameters in RBS' if kind == :block
        t = String === @type ? @type : @type.generate_rbs
        t = "^#{t}" if Types::Proc === @type
        if RBS_KEYWORDS.include? name_without_kind
          unless $VERBOSE.nil?
            print Rainbow("Parlour warning: ").yellow.dark.bold
            print Rainbow("RBS generation: ").magenta.bright.bold
            puts "'#{name_without_kind}' is a keyword in RBS, renaming method parameter to '_#{name_without_kind}'"
          end
          n = "_#{name_without_kind}"
        else
          n = name_without_kind
        end
        ((required || (kind != :normal && kind != :keyword)) ? '' : '?') + if kind == :keyword
          "#{n}: #{t}"
        else
          "#{PREFIXES[kind]}#{t} #{n}"
        end
      end
def to_rbs_param raise 'blocks are not parameters in RBS' if kind == :block t = String === @type ? @type : @type . generate_rbs t = "^#{t}" if Types :: Proc === @type if RBS_KEYWORDS . include? name_without_kind unless $VERBOSE . nil? print Rainbow ( "Parlour warning: " ) . yellow . dark . bold print Rainbow ( "RBS generation: " ) . magenta . bright . bold puts "'#{name_without_kind}' is a keyword in RBS, renaming method parameter to '_#{name_without_kind}'" end n = "_#{name_without_kind}" else n = name_without_kind end ( ( required || ( kind != :normal && kind != :keyword ) ) ? '' : '?' ) + if kind == :keyword "#{n}: #{t}" else "#{PREFIXES[kind]}#{t} #{n}" end end
A string of how this parameter should be defined in an RBS signature.
A string of how this parameter should be defined in an RBS signature .
# Extra check because "?*something" is invalid
None
String