Class: RBI::Sig

Inherits:
NodeWithComments show all
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, allow_incompatible_override: false, without_runtime: false, type_params: [], checked: nil, loc: nil, comments: [], &block) ⇒ Sig

: (?params: Array, ?return_type: (Type | String), ?is_abstract: bool, ?is_override: bool, ?is_overridable: bool, ?is_final: bool, ?allow_incompatible_override: bool, ?without_runtime: bool, ?type_params: Array, ?checked: Symbol?, ?loc: Loc?, ?comments: Array) ?{ (Sig node) -> void } -> void



844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
# File 'lib/rbi/model.rb', line 844

def initialize(
  params: [],
  return_type: "void",
  is_abstract: false,
  is_override: false,
  is_overridable: false,
  is_final: false,
  allow_incompatible_override: false,
  without_runtime: 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
  @allow_incompatible_override = allow_incompatible_override
  @without_runtime = without_runtime
  @type_params = type_params
  @checked = checked
  block&.call(self)
end

Instance Attribute Details

#allow_incompatible_overrideObject

: bool



835
836
837
# File 'lib/rbi/model.rb', line 835

def allow_incompatible_override
  @allow_incompatible_override
end

#checkedObject

: Symbol?



841
842
843
# File 'lib/rbi/model.rb', line 841

def checked
  @checked
end

#is_abstractObject

: bool



835
836
837
# File 'lib/rbi/model.rb', line 835

def is_abstract
  @is_abstract
end

#is_finalObject

: bool



835
836
837
# File 'lib/rbi/model.rb', line 835

def is_final
  @is_final
end

#is_overridableObject

: bool



835
836
837
# File 'lib/rbi/model.rb', line 835

def is_overridable
  @is_overridable
end

#is_overrideObject

: bool



835
836
837
# File 'lib/rbi/model.rb', line 835

def is_override
  @is_override
end

#paramsObject (readonly)

: Array



829
830
831
# File 'lib/rbi/model.rb', line 829

def params
  @params
end

#return_typeObject

: (Type | String)



832
833
834
# File 'lib/rbi/model.rb', line 832

def return_type
  @return_type
end

#type_paramsObject (readonly)

: Array



838
839
840
# File 'lib/rbi/model.rb', line 838

def type_params
  @type_params
end

#without_runtimeObject

: bool



835
836
837
# File 'lib/rbi/model.rb', line 835

def without_runtime
  @without_runtime
end

Instance Method Details

#<<(param) ⇒ Object

: (SigParam param) -> void



874
875
876
# File 'lib/rbi/model.rb', line 874

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

#==(other) ⇒ Object

: (Object other) -> bool



884
885
886
887
888
889
890
# File 'lib/rbi/model.rb', line 884

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 &&
    without_runtime == other.without_runtime && type_params == other.type_params && checked == other.checked
end

#add_param(name, type) ⇒ Object

: (String name, (Type | String) type) -> void



879
880
881
# File 'lib/rbi/model.rb', line 879

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