Class: ArchUnit::Common::Extraction::Graph
- Inherits:
-
Object
- Object
- ArchUnit::Common::Extraction::Graph
- Includes:
- Enumerable
- Defined in:
- lib/archunit/common/extraction/graph.rb
Overview
An immutable, enumerable list of dependency edges.
Instance Attribute Summary collapse
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #[] ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(edges = []) ⇒ Graph
constructor
A new instance of Graph.
- #size ⇒ Object (also: #length)
- #to_a ⇒ Object
Constructor Details
#initialize(edges = []) ⇒ Graph
Returns a new instance of Graph.
14 15 16 17 18 19 20 21 22 |
# File 'lib/archunit/common/extraction/graph.rb', line 14 def initialize(edges = []) @edges = Array(edges).dup invalid_edges = @edges.grep_v(Edge) raise ArgumentError, 'graph accepts only Edge values' unless invalid_edges.empty? validate_identifier_style @edges.freeze freeze end |
Instance Attribute Details
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
12 13 14 |
# File 'lib/archunit/common/extraction/graph.rb', line 12 def edges @edges end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
45 46 47 |
# File 'lib/archunit/common/extraction/graph.rb', line 45 def ==(other) other.is_a?(Graph) && edges == other.edges end |
#[] ⇒ Object
28 29 30 |
# File 'lib/archunit/common/extraction/graph.rb', line 28 def [](*) edges[*] end |
#each ⇒ Object
24 25 26 |
# File 'lib/archunit/common/extraction/graph.rb', line 24 def each(&) edges.each(&) end |
#empty? ⇒ Boolean
37 38 39 |
# File 'lib/archunit/common/extraction/graph.rb', line 37 def empty? edges.empty? end |
#hash ⇒ Object
50 51 52 |
# File 'lib/archunit/common/extraction/graph.rb', line 50 def hash [self.class, edges].hash end |
#size ⇒ Object Also known as: length
32 33 34 |
# File 'lib/archunit/common/extraction/graph.rb', line 32 def size edges.size end |
#to_a ⇒ Object
41 42 43 |
# File 'lib/archunit/common/extraction/graph.rb', line 41 def to_a edges.dup end |