Class: EmailGraph::DirectedEdge

Inherits:
Object
  • Object
show all
Defined in:
lib/email_graph/directed_graph.rb

Direct Known Subclasses

InteractionRelationship

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to) ⇒ DirectedEdge

Returns a new instance of DirectedEdge.

Raises:

  • (ArgumentError)


102
103
104
105
106
# File 'lib/email_graph/directed_graph.rb', line 102

def initialize(from, to)
  raise ArgumentError, "Vertices cannot be falsy" unless from && to
  @from = from
  @to = to
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



99
100
101
# File 'lib/email_graph/directed_graph.rb', line 99

def from
  @from
end

#toObject (readonly)

Returns the value of attribute to.



100
101
102
# File 'lib/email_graph/directed_graph.rb', line 100

def to
  @to
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



112
113
114
# File 'lib/email_graph/directed_graph.rb', line 112

def ==(other)
  from == other.from && to == other.to
end

#hashObject



108
109
110
# File 'lib/email_graph/directed_graph.rb', line 108

def hash
  from.hash ^ to.hash
end

#to_sObject



117
118
119
# File 'lib/email_graph/directed_graph.rb', line 117

def to_s
  "(#{from}-#{to})"
end