Class: Graphm::Edge
- Inherits:
-
Object
- Object
- Graphm::Edge
- Defined in:
- lib/graphm/edge.rb
Instance Attribute Summary collapse
-
#dst ⇒ Object
readonly
Returns the value of attribute dst.
-
#prop ⇒ Object
readonly
Returns the value of attribute prop.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
Instance Method Summary collapse
- #has_prop?(key, val = nil) ⇒ Boolean
-
#initialize(src, dst, prop = {}) ⇒ Edge
constructor
A new instance of Edge.
- #set_prop(prop) ⇒ Object
Constructor Details
#initialize(src, dst, prop = {}) ⇒ Edge
Returns a new instance of Edge.
7 8 9 10 11 12 |
# File 'lib/graphm/edge.rb', line 7 def initialize src, dst, prop={} @src = src @dst = dst @prop = {} set_prop prop end |
Instance Attribute Details
#dst ⇒ Object (readonly)
Returns the value of attribute dst.
5 6 7 |
# File 'lib/graphm/edge.rb', line 5 def dst @dst end |
#prop ⇒ Object (readonly)
Returns the value of attribute prop.
5 6 7 |
# File 'lib/graphm/edge.rb', line 5 def prop @prop end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
5 6 7 |
# File 'lib/graphm/edge.rb', line 5 def src @src end |
Instance Method Details
#has_prop?(key, val = nil) ⇒ Boolean
20 21 22 23 24 25 26 27 |
# File 'lib/graphm/edge.rb', line 20 def has_prop? key, val=nil res = if @prop.include? key then @prop[key] else false end return res end |
#set_prop(prop) ⇒ Object
14 15 16 17 18 |
# File 'lib/graphm/edge.rb', line 14 def set_prop prop prop.each do |k,v| @prop[k] = v end end |