class RBS::Definition::Method - rbs: Ruby Standard Library Documentation

# class RBS::Definition::Method

### Attributes

accessibility[R]
alias_of[R]
defs[R]
extra_annotations[R]
super_method[R]

### Public Class Methods

new(super_method:, defs:, accessibility:, annotations: [], alias_of:) click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 83
    def initialize(super_method:, defs:, accessibility:, annotations: [], alias_of:)
      @super_method = super_method
      @defs = defs
      @accessibility = accessibility
      @extra_annotations = []
      @alias_of = alias_of
    end

### Public Instance Methods

==(other) click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 91
    def ==(other)
      other.is_a?(Method) &&
        other.super_method == super_method &&
        other.defs == defs &&
        other.accessibility == accessibility &&
        other.annotations == annotations &&
        other.alias_of == alias_of
    end

Also aliased as: eql?
annotations() click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 128
    def annotations
      @annotations ||= defs.flat_map {|d| d.member_annotations }
    end

comments() click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 124
    def comments
      @comments ||= defs.map(&:comment).compact.uniq
    end

defined_in() click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 106
    def defined_in
      @defined_in ||= begin
        last_def = defs.last or raise
        last_def.defined_in
      end
    end

eql?(other)
Alias for: ==
hash() click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 102
    def hash
      self.class.hash ^ super_method.hash ^ defs.hash ^ accessibility.hash ^ annotations.hash ^ alias_of.hash
    end

implemented_in() click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 113
    def implemented_in
      @implemented_in ||= begin
        last_def = defs.last or raise
        last_def.implemented_in
      end
    end

map_method_type() { |type| ... } click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 171
    def map_method_type(&block)
      self.class.new(
        super_method: super_method,
        defs: defs.map {|defn| defn.update(type: yield(defn.type)) },
        accessibility: @accessibility,
        alias_of: alias_of
      )
    end

map_type(&block) click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 153
    def map_type(&block)
      self.class.new(
        super_method: super_method&.map_type(&block),
        defs: defs.map {|defn| defn.update(type: defn.type.map_type(&block)) },
        accessibility: @accessibility,
        alias_of: alias_of
      )
    end

map_type_bound(&block) click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 162
    def map_type_bound(&block)
      self.class.new(
        super_method: super_method&.map_type_bound(&block),
        defs: defs.map {|defn| defn.update(type: defn.type.map_type_bound(&block)) },
        accessibility: @accessibility,
        alias_of: alias_of
      )
    end

members() click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 132
    def members
      @members ||= defs.map(&:member).uniq
    end

method_types() click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 120
    def method_types
      @method_types ||= defs.map(&:type)
    end

private?() click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 140
    def private?
      @accessibility == :private
    end

public?() click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 136
    def public?
      @accessibility == :public
    end

sub(s) click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 144
    def sub(s)
      self.class.new(
        super_method: super_method&.sub(s),
        defs: defs.map {|defn| defn.update(type: defn.type.sub(s)) },
        accessibility: @accessibility,
        alias_of: alias_of
      )
    end

update(super_method: self.super_method, defs: self.defs, accessibility: self.accessibility, alias_of: self.alias_of, annotations: self.annotations) click to toggle source

    # File rbs-3.8.0/lib/rbs/definition.rb, line 180
    def update(super_method: self.super_method, defs: self.defs, accessibility: self.accessibility, alias_of: self.alias_of, annotations: self.annotations)
      self.class.new(
        super_method: super_method,
        defs: defs,
        accessibility: accessibility,
        alias_of: alias_of,
        annotations: annotations
      )
    end