Sha256: 965c15e4484204ddfd8fa44abe6b4c174115ef8c4b717d7fbec2192bb5fbf734

Contents?: true

Size: 1.82 KB

Versions: 43

Compression:

Stored size: 1.82 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 private?
        attributes.include?(:private)
      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 with_types(types)
        self.class.new(
          type_name: type_name,
          name: name,
          types: types,
          super_method: super_method,
          attributes: attributes
        )
      end

      def map_types
        with_types(types.map {|type| yield type })
      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

43 entries across 43 versions & 1 rubygems

Version Path
steep-0.31.0 lib/steep/interface/method.rb
steep-0.30.0 lib/steep/interface/method.rb
steep-0.29.0 lib/steep/interface/method.rb
steep-0.28.0 lib/steep/interface/method.rb
steep-0.27.0 lib/steep/interface/method.rb
steep-0.25.0 lib/steep/interface/method.rb
steep-0.24.0 lib/steep/interface/method.rb
steep-0.23.0 lib/steep/interface/method.rb
steep-0.22.0 lib/steep/interface/method.rb
steep-0.21.0 lib/steep/interface/method.rb
steep-0.20.0 lib/steep/interface/method.rb
steep-0.19.0 lib/steep/interface/method.rb
steep-0.18.0 lib/steep/interface/method.rb
steep-0.17.1 lib/steep/interface/method.rb
steep-0.17.0 lib/steep/interface/method.rb
steep-0.16.3 lib/steep/interface/method.rb
steep-0.16.2 lib/steep/interface/method.rb
steep-0.16.1 lib/steep/interface/method.rb
steep-0.16.0 lib/steep/interface/method.rb
steep-0.15.0 lib/steep/interface/method.rb