Class: Yoda::Model::LexicalContext

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/yoda/model/lexical_context.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths:) ⇒ LexicalContext

Returns a new instance of LexicalContext.

Parameters:

  • paths (Array<Path>)


14
15
16
# File 'lib/yoda/model/lexical_context.rb', line 14

def initialize(paths:)
  @paths = paths
end

Instance Attribute Details

#pathsArray<Path> (readonly)

Returns:



7
8
9
# File 'lib/yoda/model/lexical_context.rb', line 7

def paths
  @paths
end

Class Method Details

.build(paths) ⇒ Object



9
10
11
# File 'lib/yoda/model/lexical_context.rb', line 9

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

Instance Method Details

#==(another) ⇒ Object



27
28
29
# File 'lib/yoda/model/lexical_context.rb', line 27

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

#each(&block) ⇒ Object



23
24
25
# File 'lib/yoda/model/lexical_context.rb', line 23

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

#eql?(another) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/yoda/model/lexical_context.rb', line 31

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

#hashObject



35
36
37
# File 'lib/yoda/model/lexical_context.rb', line 35

def hash
  paths.hash
end

#to_rbs_contextArray<RBS::Namespace>

Returns:

  • (Array<RBS::Namespace>)


19
20
21
# File 'lib/yoda/model/lexical_context.rb', line 19

def to_rbs_context
  paths.map { |path| Namespace(path.to_s) }
end