Sha256: 413dbb3b6073d7b3efce79779e5b622323da17d495220529064d9672cff96b71
Contents?: true
Size: 946 Bytes
Versions: 6
Compression:
Stored size: 946 Bytes
Contents
# Author:: Eric Crane (mailto:eric.crane@mac.com) # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved. # # Data conversion manager. # module GlooLang module Convert class Converter # --------------------------------------------------------------------- # Convert # --------------------------------------------------------------------- # # Convert the given value to the specified type, # or if no conversion is available, revert to default. # def convert( value, to_type, default = nil ) begin name = "GlooLang::Convert::#{value.class}To#{to_type}" clazz = name.split( '::' ).inject( Object ) { |o, c| o.const_get c } o = clazz.new return o.convert( value ) rescue => e $log.error e.message $engine.heap.error.set_to e.message end return default end end end end
Version data entries
6 entries across 6 versions & 1 rubygems