Class: RBI::Sig

Inherits:
NodeWithComments show all
Extended by:
T::Sig
Defined in:
lib/rbi/model.rb

Overview

Sorbet’s sigs

Instance Attribute Summary collapse

Attributes inherited from NodeWithComments

#comments

Attributes inherited from Node

#loc, #parent_tree

Instance Method Summary collapse

Methods inherited from NodeWithComments

#annotations, #merge_with, #version_requirements

Methods inherited from Node

#compatible_with?, #detach, #merge_with, #parent_conflict_tree, #parent_scope, #print, #rbs_print, #rbs_string, #replace, #satisfies_version?, #string

Constructor Details

#initialize(params: [], return_type: "void", is_abstract: false, is_override: false, is_overridable: false, is_final: false, type_params: [], checked: nil, loc: nil, comments: [], &block) ⇒ Sig

Returns a new instance of Sig.



1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
# File 'lib/rbi/model.rb', line 1137

def initialize(
  params: [],
  return_type: "void",
  is_abstract: false,
  is_override: false,
  is_overridable: false,
  is_final: false,
  type_params: [],
  checked: nil,
  loc: nil,
  comments: [],
  &block
)
  super(loc: loc, comments: comments)
  @params = params
  @return_type = return_type
  @is_abstract = is_abstract
  @is_override = is_override
  @is_overridable = is_overridable
  @is_final = is_final
  @type_params = type_params
  @checked = checked
  block&.call(self)
end

Instance Attribute Details

#checkedObject

Returns the value of attribute checked.



1120
1121
1122
# File 'lib/rbi/model.rb', line 1120

def checked
  @checked
end

#is_abstractObject

Returns the value of attribute is_abstract.



1114
1115
1116
# File 'lib/rbi/model.rb', line 1114

def is_abstract
  @is_abstract
end

#is_finalObject

Returns the value of attribute is_final.



1114
1115
1116
# File 'lib/rbi/model.rb', line 1114

def is_final
  @is_final
end

#is_overridableObject

Returns the value of attribute is_overridable.



1114
1115
1116
# File 'lib/rbi/model.rb', line 1114

def is_overridable
  @is_overridable
end

#is_overrideObject

Returns the value of attribute is_override.



1114
1115
1116
# File 'lib/rbi/model.rb', line 1114

def is_override
  @is_override
end

#paramsObject (readonly)

Returns the value of attribute params.



1108
1109
1110
# File 'lib/rbi/model.rb', line 1108

def params
  @params
end

#return_typeObject

Returns the value of attribute return_type.



1111
1112
1113
# File 'lib/rbi/model.rb', line 1111

def return_type
  @return_type
end

#type_paramsObject (readonly)

Returns the value of attribute type_params.



1117
1118
1119
# File 'lib/rbi/model.rb', line 1117

def type_params
  @type_params
end

Instance Method Details

#<<(param) ⇒ Object



1163
1164
1165
# File 'lib/rbi/model.rb', line 1163

def <<(param)
  @params << param
end

#==(other) ⇒ Object



1173
1174
1175
1176
1177
1178
1179
# File 'lib/rbi/model.rb', line 1173

def ==(other)
  return false unless other.is_a?(Sig)

  params == other.params && return_type.to_s == other.return_type.to_s && is_abstract == other.is_abstract &&
    is_override == other.is_override && is_overridable == other.is_overridable && is_final == other.is_final &&
    type_params == other.type_params && checked == other.checked
end

#add_param(name, type) ⇒ Object



1168
1169
1170
# File 'lib/rbi/model.rb', line 1168

def add_param(name, type)
  @params << SigParam.new(name, type)
end