Sha256: cb3a3b75cc04116037decdb3f7c8ec1c7a3bef08757e591f4cf743257dbd6acc
Contents?: true
Size: 599 Bytes
Versions: 9
Compression:
Stored size: 599 Bytes
Contents
# frozen_string_literal: true require_relative 'builtin_datatype' module Loxxy module Datatype # Class for representing a Lox numeric value. class Number < BuiltinDatatype protected def validated_value(aValue) case aValue when Integer, Numeric result = aValue when /^-?\d+$/ result = aValue.to_i when /^-?\d+\.\d+$/ result = aValue.to_f else raise StandardError, "Invalid number value #{aValue}" end result end end # class end # module end # module
Version data entries
9 entries across 9 versions & 1 rubygems