Skip to content
Permalink
Browse files

Merge pull request #782 from kostya/int

kernel#Integer more tags
  • Loading branch information
alex committed Jun 30, 2013
2 parents 91f5e66 + aa2e33f commit 42f3eca2338dbb0f9b52042ede1674f42ee7d197
Showing with 142 additions and 148 deletions.
  1. +17 −2 lib-topaz/kernel.rb
  2. +123 −146 spec/tags/core/kernel/Integer_tags.txt
  3. +2 −0 topaz/objects/stringobject.py
@@ -40,9 +40,24 @@ def String(arg)
module_function :String
private :String

def Integer(arg)
arg.to_i
def Integer(arg, base = nil)
if arg.kind_of?(String)
if arg.empty?
raise ArgumentError.new("invalid value for Integer(): \"\"")
else
return arg.to_i(base || 0)
end
end

raise ArgumentError.new("base specified for non string value") if base
return Topaz.convert_type(arg, Fixnum, :to_int) if arg.nil?

if arg.respond_to?(:to_int) && val = arg.to_int
return val
end
Topaz.convert_type(arg, Fixnum, :to_i)
end

module_function :Integer
private :Integer

0 comments on commit 42f3eca

Please sign in to comment.
You can’t perform that action at this time.