brainstorm
Member
Fixnum to String Script
Okay, I admit this is really kinda useless, but I made a script that (badly) converts Intergers to Words. The reason I say badly is because, if you put in something like 1065 it come out as TenSixFive, instead of One Thousand Sixty-Five. But Anyway, I think someone could go far with this, but I just made it for my needs, so...
To Use it just put something like:
:cheers:
Okay, I admit this is really kinda useless, but I made a script that (badly) converts Intergers to Words. The reason I say badly is because, if you put in something like 1065 it come out as TenSixFive, instead of One Thousand Sixty-Five. But Anyway, I think someone could go far with this, but I just made it for my needs, so...
Code:
#==============================================================================
# ** Fixnum
#------------------------------------------------------------------------------
# ???
#==============================================================================
class Fixnum
def to_word
if self == 1
return "One"
elsif self == 2
return "Two"
elsif self == 3
return "Three"
elsif self == 4
return "Four"
elsif self == 5
return "Five"
elsif self == 6
return "Six"
elsif self == 7
return "Seven"
elsif self == 8
return "Eight"
elsif self == 9
return "Nine"
elsif self == 10
return "Ten"
end
end
end
To Use it just put something like:
Code:
p = 10
p.to_word
:cheers: