Class: EmailGraph::UndirectedEdge
- Inherits:
-
Object
- Object
- EmailGraph::UndirectedEdge
- Defined in:
- lib/email_graph/undirected_graph.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#vertices ⇒ Object
readonly
Returns the value of attribute vertices.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(v, w) ⇒ UndirectedEdge
constructor
A new instance of UndirectedEdge.
- #to_s ⇒ Object
Constructor Details
#initialize(v, w) ⇒ UndirectedEdge
Returns a new instance of UndirectedEdge.
46 47 48 49 |
# File 'lib/email_graph/undirected_graph.rb', line 46 def initialize(v, w) raise ArgumentError, "Vertices cannot be falsy" unless v && w @vertices = Set.new([v, w]) end |
Instance Attribute Details
#vertices ⇒ Object (readonly)
Returns the value of attribute vertices.
44 45 46 |
# File 'lib/email_graph/undirected_graph.rb', line 44 def vertices @vertices end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
55 56 57 |
# File 'lib/email_graph/undirected_graph.rb', line 55 def ==(other) @vertices == other.vertices end |
#hash ⇒ Object
51 52 53 |
# File 'lib/email_graph/undirected_graph.rb', line 51 def hash @vertices.hash end |
#to_s ⇒ Object
60 61 62 63 |
# File 'lib/email_graph/undirected_graph.rb', line 60 def to_s a = @vertices.to_a "(#{a[0]}-#{a[1]})" end |