Sha256: f6f1165d9ea4522221ca852b01a23a1dca60ca37efced7a222f44e380c9cdbd8
Contents?: true
Size: 713 Bytes
Versions: 6
Compression:
Stored size: 713 Bytes
Contents
class Link attr_accessor :source, :target, :type def initialize(arg) @args = arg @source = @args.delete(:source) @target = @args.delete(:target) @type = @args.delete(:type) || 'undirected' raise Exception.new("source cant be nil") unless @source raise Exception.new("target cant be nil") unless @target raise Exception.new("source must be of type Node") unless @source.is_a? Node raise Exception.new("target must be of type Node") unless @target.is_a? Node @args[:weight] ||= 1 @source.neighbours << @target @target.neighbours << @source unless @type == 'directed' end def method_missing(name, *args) super unless args.empty? @args[name] end end
Version data entries
6 entries across 6 versions & 1 rubygems