Sha256: 7ebed7cf38836d0b91a76ad7598997ba0b21707c6f95f82d68c4168b8924fc5f

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

module Steep
  module Interface
    class Method
      attr_reader :type_name
      attr_reader :name
      attr_reader :super_method
      attr_reader :types
      attr_reader :attributes

      def initialize(type_name:, name:, types:, super_method:, attributes:)
        @type_name = type_name
        @name = name
        @types = types
        @super_method = super_method
        @attributes = attributes
      end

      def ==(other)
        other.is_a?(Method) &&
          other.type_name == type_name &&
          other.name == name &&
          other.types == types &&
          other.super_method == super_method &&
          other.attributes == attributes
      end

      def closed?
        types.all?(&:closed?)
      end

      def subst(s)
        self.class.new(
          type_name: type_name,
          name: name,
          types: types.map {|type| type.subst(s) },
          super_method: super_method&.subst(s),
          attributes: attributes
        )
      end

      def with_super(super_method)
        self.class.new(
          type_name: type_name,
          name: name,
          types: types,
          super_method: super_method,
          attributes: attributes
        )
      end

      def include_in_chain?(method)
        (method.type_name == type_name &&
          method.name == name &&
          method.types == types &&
          method.attributes == attributes) ||
          super_method&.include_in_chain?(method)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
steep-0.3.0 lib/steep/interface/method.rb
steep-0.2.0 lib/steep/interface/method.rb
steep-0.1.0 lib/steep/interface/method.rb