Class: RBS::Definition::Method::TypeDef

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, member:, defined_in:, implemented_in:) ⇒ TypeDef

Returns a new instance of TypeDef.



30
31
32
33
34
35
# File 'lib/rbs/definition.rb', line 30

def initialize(type:, member:, defined_in:, implemented_in:)
  @type = type
  @member = member
  @defined_in = defined_in
  @implemented_in = implemented_in
end

Instance Attribute Details

#defined_inObject (readonly)

Returns the value of attribute defined_in.



27
28
29
# File 'lib/rbs/definition.rb', line 27

def defined_in
  @defined_in
end

#implemented_inObject (readonly)

Returns the value of attribute implemented_in.



28
29
30
# File 'lib/rbs/definition.rb', line 28

def implemented_in
  @implemented_in
end

#memberObject (readonly)

Returns the value of attribute member.



26
27
28
# File 'lib/rbs/definition.rb', line 26

def member
  @member
end

#typeObject (readonly)

Returns the value of attribute type.



25
26
27
# File 'lib/rbs/definition.rb', line 25

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



37
38
39
40
41
42
43
# File 'lib/rbs/definition.rb', line 37

def ==(other)
  other.is_a?(TypeDef) &&
    other.type == type &&
    other.member == member &&
    other.defined_in == defined_in &&
    other.implemented_in == implemented_in
end

#annotationsObject



55
56
57
# File 'lib/rbs/definition.rb', line 55

def annotations
  member.annotations
end

#commentObject



51
52
53
# File 'lib/rbs/definition.rb', line 51

def comment
  member.comment
end

#hashObject



47
48
49
# File 'lib/rbs/definition.rb', line 47

def hash
  self.class.hash ^ type.hash ^ member.hash ^ defined_in.hash ^ implemented_in.hash
end

#overload?Boolean

Returns:

  • (Boolean)


63
64
65
66
67
68
69
70
# File 'lib/rbs/definition.rb', line 63

def overload?
  case mem = member
  when AST::Members::MethodDefinition
    mem.overload?
  else
    false
  end
end

#update(type: self.type, member: self.member, defined_in: self.defined_in, implemented_in: self.implemented_in) ⇒ Object



59
60
61
# File 'lib/rbs/definition.rb', line 59

def update(type: self.type, member: self.member, defined_in: self.defined_in, implemented_in: self.implemented_in)
  TypeDef.new(type: type, member: member, defined_in: defined_in, implemented_in: implemented_in)
end