Class: Yoda::Model::ScopedPath
- Inherits:
-
Object
- Object
- Yoda::Model::ScopedPath
- Defined in:
- lib/yoda/model/scoped_path.rb
Overview
ScopedPath represents a path name written in namespaces. ScopedPath owns lexical scopes where the path is written.
Instance Attribute Summary collapse
- #path ⇒ Path readonly
-
#scopes ⇒ Array<Path>
readonly
Represents namespaces in order of nearness.
Class Method Summary collapse
Instance Method Summary collapse
- #==(another) ⇒ Object
- #change_scope(paths) ⇒ ScopedPath
- #eql?(another) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(scopes, path) ⇒ ScopedPath
constructor
A new instance of ScopedPath.
Constructor Details
#initialize(scopes, path) ⇒ ScopedPath
Returns a new instance of ScopedPath.
20 21 22 23 |
# 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 |
Instance Attribute Details
#scopes ⇒ Array<Path> (readonly)
Returns represents namespaces in order of nearness.
7 8 9 |
# File 'lib/yoda/model/scoped_path.rb', line 7 def scopes @scopes end |
Class Method Details
.build(path) ⇒ ScopedPath
14 15 16 |
# 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 |
Instance Method Details
#==(another) ⇒ Object
35 36 37 |
# File 'lib/yoda/model/scoped_path.rb', line 35 def ==(another) eql?(another) end |
#change_scope(paths) ⇒ ScopedPath
27 28 29 |
# File 'lib/yoda/model/scoped_path.rb', line 27 def change_scope(paths) self.class.new(paths, path) end |
#eql?(another) ⇒ Boolean
39 40 41 |
# File 'lib/yoda/model/scoped_path.rb', line 39 def eql?(another) another.is_a?(ScopedPath) && path == another.path && scopes == another.scopes end |
#hash ⇒ Object
31 32 33 |
# File 'lib/yoda/model/scoped_path.rb', line 31 def hash [self.class.name, scopes, path].hash end |