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:) ⇒ MethodDefinition

[ GitHub ]

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

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

Instance Attribute Details

#annotations (readonly)

[ GitHub ]

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

attr_reader :annotations

#comment (readonly)

[ GitHub ]

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

attr_reader :comment

#instance?Boolean (readonly)

[ GitHub ]

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

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

#kind (readonly)

[ GitHub ]

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

attr_reader :kind

#location (readonly)

[ GitHub ]

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

attr_reader :location

#name (readonly)

[ GitHub ]

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

attr_reader :name

#overload (readonly)

[ GitHub ]

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

attr_reader :overload

#overload?Boolean (readonly)

[ GitHub ]

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

def overload?
  overload
end

#singleton?Boolean (readonly)

[ GitHub ]

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

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

#types (readonly)

[ GitHub ]

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

attr_reader :types

Instance Method Details

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

[ GitHub ]

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

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

#eql?(other)

Alias for #==.

[ GitHub ]

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

alias eql? ==

#hash

[ GitHub ]

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

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

#to_json(state = _ = nil)

[ GitHub ]

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

def to_json(state = _ = nil)
  {
    member: :method_definition,
    kind: kind,
    types: types,
    annotations: annotations,
    location: location,
    comment: comment,
    overload: overload
  }.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)

[ GitHub ]

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

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