class Yoda::Model::ScopedPath

ScopedPath represents a path name written in namespaces. ScopedPath owns lexical scopes where the path is written.

Attributes

path[R]

@return [Path]

scopes[R]

@return [Array<Path>] represents namespaces in order of nearness.

Public Class Methods

build(path) click to toggle source

@param path [Path] @return [ScopedPath]

# File lib/yoda/model/scoped_path.rb, line 14
def self.build(path)
  path.is_a?(ScopedPath) ? path : ScopedPath.new(['Object'], Path.build(path))
end
new(scopes, path) click to toggle source

@param scopes [Array<Path>] represents namespaces in order of nearness. @param path [Path]

# File lib/yoda/model/scoped_path.rb, line 20
def initialize(scopes, path)
  @scopes = scopes.map { |pa| Path.build(pa) }
  @path = Path.build(path)
end

Public Instance Methods

==(another) click to toggle source
# File lib/yoda/model/scoped_path.rb, line 35
def ==(another)
  eql?(another)
end
change_scope(paths) click to toggle source

@param paths [Array<String, Path>] @return [ScopedPath]

# File lib/yoda/model/scoped_path.rb, line 27
def change_scope(paths)
  self.class.new(paths, path)
end
eql?(another) click to toggle source
# File lib/yoda/model/scoped_path.rb, line 39
def eql?(another)
  another.is_a?(ScopedPath) && path == another.path && scopes == another.scopes
end
hash() click to toggle source
# File lib/yoda/model/scoped_path.rb, line 31
def hash
  [self.class.name, scopes, path].hash
end