title: Sub-classing Fixnum in ruby
body: <p>So I understand you aren't supposed to to directly subclass Fixnum, Float or Integer, as they don't have a #new method. Using DelegateClass seems to work though, but is it the best way? Anyone know what the reason behind these classes not having #new is?</p>
  
  <p>I need a class which behaves like a Fixnum, but has some extra methods, and I'd like to be able to refer to its value through <code>self</code> from within the class, for example:</p>
  
  <pre><code>class Foo &lt; Fixnum
    def initialize value
      super value
    end
  
    def increment
      self + 1
    end
  end
  
  Foo.new(5).increment + 4 # =&gt; 10
  </code></pre>