Class: Link
- Inherits:
-
Object
- Object
- Link
- Defined in:
- lib/rgraph/link.rb
Instance Method Summary collapse
-
#initialize(arg) ⇒ Link
constructor
attr_accessor :source, :target.
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(arg) ⇒ Link
attr_accessor :source, :target
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rgraph/link.rb', line 4 def initialize(arg) @args = arg if @args[:source] == nil raise Exception.new("source cant be nil") end if @args[:target] == nil raise Exception.new("target cant be nil") end if not @args[:source].is_a? Node raise Exception.new("source must be of type Node") end if not @args[:target].is_a? Node raise Exception.new("target must be of type Node") end @args[:weight] ||= 1 @args[:source].neighbours << @args[:target] @args[:target].neighbours << @args[:source] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
28 29 30 31 |
# File 'lib/rgraph/link.rb', line 28 def method_missing(name, *args) super unless args.empty? @args[name] end |