Class: Connected::GenericConnection

Inherits:
Object
  • Object
show all
Includes:
Edge
Defined in:
lib/connected/generic_connection.rb

Overview

A generic implementation of an Edge

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Edge

#<=>, #closed?, #open?

Constructor Details

#initialize(from:, to:, metric: 1, state: :open) ⇒ GenericConnection

Returns a new instance of GenericConnection.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/connected/generic_connection.rb', line 10

def initialize(from:, to:, metric: 1, state: :open)
  validate_from(from)
  validate_to(to)
  validate_metric(metric)
  validate_state(state)

  raise "Invalid Connection from and to same Vertex" if from == to

  @from = from
  @to = to
  @metric = metric
  @state = state
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



8
9
10
# File 'lib/connected/generic_connection.rb', line 8

def from
  @from
end

#metricObject

Returns the value of attribute metric.



8
9
10
# File 'lib/connected/generic_connection.rb', line 8

def metric
  @metric
end

#stateObject

Returns the value of attribute state.



8
9
10
# File 'lib/connected/generic_connection.rb', line 8

def state
  @state
end

#toObject (readonly)

Returns the value of attribute to.



8
9
10
# File 'lib/connected/generic_connection.rb', line 8

def to
  @to
end