Class: Face
- Inherits:
-
Object
- Object
- Face
- Defined in:
- lib/zadt/AbstractDataTypes/Graph/face.rb
Overview
require_relative ‘vertex.rb’ require_relative ‘edge.rb’
Instance Attribute Summary collapse
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
-
#value ⇒ Object
Contains.
-
#vertices ⇒ Object
readonly
Returns the value of attribute vertices.
Instance Method Summary collapse
-
#initialize(edges_array, value = Hash.new) ⇒ Face
constructor
A new instance of Face.
- #inspect ⇒ Object
Constructor Details
#initialize(edges_array, value = Hash.new) ⇒ Face
Returns a new instance of Face.
8 9 10 11 12 13 14 15 |
# File 'lib/zadt/AbstractDataTypes/Graph/face.rb', line 8 def initialize(edges_array, value = Hash.new) raise "not enough edges" if edges_array.length < 3 edges_array.each {|edge| raise "not an edge" unless edge.is_a?(Edge)} @edges = edges_array vertices = edges_array.map{ |edge| edge.connection}.inject(:+).uniq @vertices = ensure_cyclic(vertices) @value = value end |
Instance Attribute Details
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
4 5 6 |
# File 'lib/zadt/AbstractDataTypes/Graph/face.rb', line 4 def edges @edges end |
#value ⇒ Object
Contains
6 7 8 |
# File 'lib/zadt/AbstractDataTypes/Graph/face.rb', line 6 def value @value end |
#vertices ⇒ Object (readonly)
Returns the value of attribute vertices.
4 5 6 |
# File 'lib/zadt/AbstractDataTypes/Graph/face.rb', line 4 def vertices @vertices end |
Instance Method Details
#inspect ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/zadt/AbstractDataTypes/Graph/face.rb', line 17 def inspect output = "This face contains the following vertices:" output += @vertices.to_s output = "This face contains the following edges:" output += @edges.to_s output end |