Download file from this link.

class Object  
  %w(one two three four five six seven eight nine ten eleven twelve thirteen 
  fourteen fifteen sixteen seventeen eighteen nineteen).each_with_index do |english, index| 
    define_method english do
      own_value + index + 1
    end
  end

  %w(twenty thirty forty fifty sixty seventy eighty ninety).each_with_index do |english, index|
    define_method english do 
      own_value + 20 + (index * 10) 
    end
  end 

  private
  def own_value 
    0
  end
end 

class Integer  

  def hundred 
    return self * 100  if self <= 1000   
    self - (self % 1000) + (self % 1000 * 100)
  end 

  def thousand
    return self * 1000 if self <= 1000000
    self - (self % 1000000) + (self % 1000000 * 1000)  
  end 

  def million  
    self * 1000000
  end

  def and 
    self
  end 

  private 
  def own_value
    self
  end
end


if __FILE__ == $0    

  require 'test/unit'

  class LongNumbersTest < Test::Unit::TestCase   


    def test_1_to_19 
      assert_equal 1, one
      assert_equal 19, nineteen

      one_to_nineteen = [
        one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen,
        fourteen, fifteen,sixteen, seventeen, eighteen, nineteen
      ] 
      assert_equal (1..19).to_a, one_to_nineteen
    end                                         

    def test_20_to_90_going_up_in_tens
      assert_equal 20, twenty
      assert_equal 30, thirty
      assert_equal 40, forty
      assert_equal 50, fifty 
      assert_equal 60, sixty
      assert_equal 70, seventy
      assert_equal 80, eighty
      assert_equal 90, ninety
    end

    def test_twenties  
      assert_equal 21, twenty.one  
      assert_equal 22, twenty.two  
      assert_equal 23, twenty.three  
      assert_equal 24, twenty.four  
      assert_equal 25, twenty.five  
      assert_equal 26, twenty.six  
      assert_equal 27, twenty.seven  
      assert_equal 28, twenty.eight  
      assert_equal 29, twenty.nine  
    end  

    def test_thirties_forties_etc
      assert_equal 31, thirty.one  
      assert_equal 42, forty.two
      assert_equal 57, fifty.seven  
      assert_equal 99, ninety.nine
    end 

    def test_hundreds
      assert_equal 100, one.hundred
      assert_equal 900, nine.hundred   
      assert_equal 1500, fifteen.hundred   
    end 

    def test_thousands 
      assert_equal 1000, one.thousand
      assert_equal 8000, eight.thousand
    end

    def test_hundred_and
      assert_equal 101, one.hundred.and.one  
      assert_equal 109, one.hundred.and.nine  
      assert_equal 120, one.hundred.and.twenty 
      assert_equal 999, nine.hundred.and.ninety.nine 
      assert_equal 1099, one.thousand.and.ninety.nine 
    end 

    def test_thousands
      assert_equal 1000, one.thousand
      assert_equal 1001, one.thousand.and.one
      assert_equal 1100, one.thousand.one.hundred
      assert_equal 1200, one.thousand.two.hundred
      assert_equal 1999, one.thousand.nine.hundred.and.ninety.nine
      assert_equal 2100, two.thousand.one.hundred   
      assert_equal 999999, nine.hundred.and.ninety.nine.thousand.nine.hundred.and.ninety.nine
    end 

    def test_millions 
      assert_equal 1000000, one.million
      assert_equal 1000001, one.million.and.one   
      assert_equal 1000001, one.million.one   
      assert_equal 1001000, one.million.one.thousand  
      assert_equal 1019000, one.million.nineteen.thousand 
      assert_equal 1020000, one.million.twenty.thousand 
      assert_equal 1099000, one.million.ninety.nine.thousand 
      assert_equal 1099900, one.million.ninety.nine.thousand.nine.hundred
      assert_equal 9999999, nine.million.nine.hundred.and.ninety.nine.thousand.nine.hundred.and.ninety.nine
      assert_equal 999000000000, nine.hundred.and.ninety.nine.thousand.million
      assert_equal 999999000000, nine.hundred.and.ninety.nine.thousand.nine.hundred.and.ninety.nine.million
      assert_equal 999999999999, nine.hundred.and.ninety.nine.thousand.nine.hundred.and.ninety.nine.million.nine.hundred.and.ninety.nine.thousand.nine.hundred.and.ninety.nine
    end 
    
  end
  
end