Sha256: 5a727534b6b3e595b0473cd9dfce490f6a309d134e4cf4d079273d7fb9c459b5
Contents?: true
Size: 735 Bytes
Versions: 2
Compression:
Stored size: 735 Bytes
Contents
# frozen_string_literal: true require_relative 'builtin_datatype' module Loxxy module Datatype # Class for representing a Lox numeric value. class Number < BuiltinDatatype # Build the sole instance def initialize(aValue) super(aValue) end protected def validated_value(aValue) case aValue when Integer result = aValue when 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
loxxy-0.0.4 | lib/loxxy/datatype/number.rb |
loxxy-0.0.3 | lib/loxxy/datatype/number.rb |