Class: Face

Inherits:
Object
  • Object
show all
Defined in:
lib/zadt/AbstractDataTypes/Graph/face.rb

Overview

require_relative ‘vertex.rb’ require_relative ‘edge.rb’

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#edgesObject (readonly)

Returns the value of attribute edges.



4
5
6
# File 'lib/zadt/AbstractDataTypes/Graph/face.rb', line 4

def edges
  @edges
end

#valueObject

Contains



6
7
8
# File 'lib/zadt/AbstractDataTypes/Graph/face.rb', line 6

def value
  @value
end

#verticesObject (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

#inspectObject



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