123456789_123456789_123456789_123456789_123456789_

Class: RBS::AST::Members::MethodDefinition

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base
Instance Chain:
self, Base
Inherits: RBS::AST::Members::Base
Defined in: lib/rbs/ast/members.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name:, kind:, types:, annotations:, location:, comment:, overload:, visibility: nil) ⇒ MethodDefinition

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 19

def initialize(name:, kind:, types:, annotations:, location:, comment:, overload:, visibility: nil)
  @name = name
  @kind = kind
  @types = types
  @annotations = annotations
  @location = location
  @comment = comment
  @overload = overload ? true : false
  @visibility = visibility
end

Instance Attribute Details

#annotations (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 13

attr_reader :annotations

#comment (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 15

attr_reader :comment

#instance?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 45

def instance?
  kind == :instance || kind == :singleton_instance
end

#kind (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 11

attr_reader :kind

#location (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 14

attr_reader :location

#name (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 10

attr_reader :name

#overload (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 16

attr_reader :overload

#overload?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 53

def overload?
  overload
end

#singleton?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 49

def singleton?
  kind == :singleton || kind == :singleton_instance
end

#types (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 12

attr_reader :types

#visibility (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 17

attr_reader :visibility

Instance Method Details

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

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 30

def ==(other)
  other.is_a?(MethodDefinition) &&
    other.name == name &&
    other.kind == kind &&
    other.types == types &&
    other.overload == overload &&
    other.visibility == visibility
end

#eql?(other)

Alias for #==.

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 39

alias eql? ==

#hash

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 41

def hash
  name.hash ^ kind.hash ^ types.hash ^ overload.hash
end

#to_json(state = _ = nil)

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 70

def to_json(state = _ = nil)
  {
    member: :method_definition,
    name: name,
    kind: kind,
    types: types,
    annotations: annotations,
    location: location,
    comment: comment,
    overload: overload,
    visibility: visibility
  }.to_json(state)
end

#update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment, overload: self.overload, visibility: self.visibility)

[ GitHub ]

  
# File 'lib/rbs/ast/members.rb', line 57

def update(name: self.name, kind: self.kind, types: self.types, annotations: self.annotations, location: self.location, comment: self.comment, overload: self.overload, visibility: self.visibility)
  self.class.new(
    name: name,
    kind: kind,
    types: types,
    annotations: annotations,
    location: location,
    comment: comment,
    overload: overload,
    visibility: visibility
  )
end