Skip to content

Instantly share code, notes, and snippets.

Created January 25, 2014 20:35
Show Gist options
  • Save anonymous/8623178 to your computer and use it in GitHub Desktop.
Save anonymous/8623178 to your computer and use it in GitHub Desktop.
==========
class def:
==========
require_relative '../GraphNode'
module Stats
class Group < GraphNode
include Comparable
attr_accessor :value
def initialize(value, graph)
super('Stats::Group::'+value.to_s, graph, [], [], [])
@value = value
end
end
def eql?(other)
self.class.equal?(other.class) &&
value == other.value
end
alias == eql?
def <=>(other)
return @value <=> other.value
end
end
==============
input/error:
==============
irb(main):007:0> load './models/data/graph/stats/Group.rb'
=> true
irb(main):008:0> testgrp = Stats::Group.new(5,nil)
=> #<Stats::Group:0x7817bcd4 @name="Stats::Group::5", @graph=nil, @childTypes=[], @dataTypes=[], @value=5, @parentTypes=[]>
irb(main):009:0> testgrp2 = Stats::Group.new(5,nil)
=> #<Stats::Group:0x11b78953 @name="Stats::Group::5", @graph=nil, @childTypes=[], @dataTypes=[], @value=5, @parentTypes=[]>
irb(main):010:0> testgrp == testgrp2
SystemStackError: stack level too deep
from org/jruby/RubyKernel.java:1119:in `eval'
from org/jruby/RubyKernel.java:1519:in `loop'
from org/jruby/RubyKernel.java:1282:in `catch'
from org/jruby/RubyKernel.java:1282:in `catch'
from C:\jruby-1.7.10\bin\irb:13:in `(root)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment