Sha256: 6d6cdea3f17bdcd1d1419dc28d7015159e35a78be2ad6d76ec306d0ef56807e2
Contents?: true
Size: 986 Bytes
Versions: 13
Compression:
Stored size: 986 Bytes
Contents
## # Object extension to allow numbered LP variables to be initialised dynamically using the following # syntax. # # [Capitalized_varname][lp var type suffix] # # Where lp var type suffix is either _b for binary, _i for integer, or _f for float. # I.e # # Rating_i is the equivalent of Rating (type integer) # Is_happy_b is the equivalent of Is_happy (type binary/boolean) ## class << Object alias_method :old_const_missing, :const_missing def const_missing(value) method_name = "#{value}".split("::")[-1] rescue "" if (("A".."Z").include?(method_name[0])) if(method_name.end_with?("b")) return BV.definition(method_name[0..(method_name[-2] == "_" ? -3 : -2)]) elsif(method_name.end_with?("i")) return IV.definition(method_name[0..(method_name[-2] == "_" ? -3 : -2)]) elsif(method_name.end_with?("f")) return LV.definition(method_name[0..(method_name[-2] == "_" ? -3 : -2)]) end end old_const_missing(value) end end
Version data entries
13 entries across 13 versions & 1 rubygems