Sha256: 790f595623b2b08bf327667129a42bf33ae55d4cc1a9a8c73e67cb4dadce76fc

Contents?: true

Size: 728 Bytes

Versions: 4

Compression:

Stored size: 728 Bytes

Contents

module Yoda
  module Model
    class LexicalContext
      include Enumerable

      # @return [Array<Path>]
      attr_reader :paths

      def self.build(paths)
        new(paths: paths.map { |pa| Path.build(pa) })
      end

      # @param paths [Array<Path>]
      def initialize(paths:)
        @paths = paths
      end

      # @return [Array<RBS::Namespace>]
      def to_rbs_context
        paths.map { |path| Namespace(path.to_s) }
      end

      def each(&block)
        paths.each(&block)
      end

      def ==(another)
        eql?(another)
      end

      def eql?(another)
        another.is_a?(LexicalContext) && paths == another.paths
      end

      def hash
        paths.hash
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yoda-language-server-0.10.1 lib/yoda/model/lexical_context.rb
yoda-language-server-0.10.0 lib/yoda/model/lexical_context.rb
yoda-language-server-0.9.0 lib/yoda/model/lexical_context.rb
yoda-language-server-0.8.0 lib/yoda/model/lexical_context.rb