Class: EmailGraph::DirectedEdge
- Inherits:
-
Object
- Object
- EmailGraph::DirectedEdge
- Defined in:
- lib/email_graph/directed_graph.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(from, to) ⇒ DirectedEdge
constructor
A new instance of DirectedEdge.
- #to_s ⇒ Object
Constructor Details
#initialize(from, to) ⇒ DirectedEdge
Returns a new instance of DirectedEdge.
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
#from ⇒ Object (readonly)
Returns the value of attribute from.
99 100 101 |
# File 'lib/email_graph/directed_graph.rb', line 99 def from @from end |
#to ⇒ Object (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 |
#hash ⇒ Object
108 109 110 |
# File 'lib/email_graph/directed_graph.rb', line 108 def hash from.hash ^ to.hash end |
#to_s ⇒ Object
117 118 119 |
# File 'lib/email_graph/directed_graph.rb', line 117 def to_s "(#{from}-#{to})" end |