Class: Dagger::Vertex
- Inherits:
-
Object
- Object
- Dagger::Vertex
- Defined in:
- lib/dagger/vertex.rb
Overview
Vertex class for Dagger, representing a filesystem directory
Instance Attribute Summary collapse
-
#inherited ⇒ Object
readonly
Returns the value of attribute inherited.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#local ⇒ Object
readonly
Returns the value of attribute local.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
Instance Method Summary collapse
- #<<(keytree) ⇒ Object
- #[](key) ⇒ Object
- #edge_added(edge) ⇒ Object
- #edge_removed(edge) ⇒ Object
- #fetch(key) ⇒ Object
-
#initialize(name) ⇒ Vertex
constructor
A new instance of Vertex.
- #name ⇒ Object (also: #to_s)
Constructor Details
#initialize(name) ⇒ Vertex
Returns a new instance of Vertex.
7 8 9 10 11 12 13 |
# File 'lib/dagger/vertex.rb', line 7 def initialize(name) initialize_forest ['_meta.name'] = name ['_meta.basename'] = File.basename(name) ['_meta.dirname'] = File.dirname(name) end |
Instance Attribute Details
#inherited ⇒ Object (readonly)
Returns the value of attribute inherited.
15 16 17 |
# File 'lib/dagger/vertex.rb', line 15 def inherited @inherited end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
15 16 17 |
# File 'lib/dagger/vertex.rb', line 15 def keys @keys end |
#local ⇒ Object (readonly)
Returns the value of attribute local.
15 16 17 |
# File 'lib/dagger/vertex.rb', line 15 def local @local end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
15 16 17 |
# File 'lib/dagger/vertex.rb', line 15 def @meta end |
Instance Method Details
#<<(keytree) ⇒ Object
31 32 33 |
# File 'lib/dagger/vertex.rb', line 31 def <<(keytree) local << keytree end |
#[](key) ⇒ Object
21 22 23 24 25 |
# File 'lib/dagger/vertex.rb', line 21 def [](key) key = KeyTree::Path[key] unless key.is_a? KeyTree::Path return inherited[key[1..-1]] if key.prefix?(KeyTree::Path['^']) keys[key] end |
#edge_added(edge) ⇒ Object
35 36 37 38 |
# File 'lib/dagger/vertex.rb', line 35 def edge_added(edge) return unless edge.head?(self) inherited << edge.tail.keys end |
#edge_removed(edge) ⇒ Object
40 41 42 43 |
# File 'lib/dagger/vertex.rb', line 40 def edge_removed(edge) return unless edge.head?(self) inherited.reject! { |tree| tree.equal?(edge.tail.keys) } end |
#fetch(key) ⇒ Object
27 28 29 |
# File 'lib/dagger/vertex.rb', line 27 def fetch(key) keys.fetch(key) end |
#name ⇒ Object Also known as: to_s
17 18 19 |
# File 'lib/dagger/vertex.rb', line 17 def name ['_meta.name'] end |