module Aquarium::Utils::NameUtils

NameUtils

Convert various strings, symbols, object ids, etc. into valid “names” that can be used as method names, etc.

Public Class Methods

make_type_or_object_key(type_or_object) click to toggle source
   # File lib/aquarium/utils/name_utils.rb
32 def self.make_type_or_object_key type_or_object
33   if Aquarium::Utils::TypeUtils.is_type?(type_or_object) 
34     make_valid_type_name type_or_object
35   else
36     make_valid_object_name type_or_object
37   end
38 end
make_valid_attr_name_from_method_name(method_name) click to toggle source
   # File lib/aquarium/utils/name_utils.rb
53 def self.make_valid_attr_name_from_method_name method_name
54   new_name = method_name.to_s
55   @@char_expr_map.keys.sort{|x,y| y.length <=> x.length}.each do |expr|
56     new_name.gsub! expr, @@char_expr_map[expr]
57   end
58   new_name.intern
59 end
make_valid_object_id_name(object_id) click to toggle source

Fixes Tracker #13864.

   # File lib/aquarium/utils/name_utils.rb
49 def self.make_valid_object_id_name object_id
50   object_id.to_s.gsub(/^-/, "_neg_")
51 end
make_valid_object_name(type_or_object) click to toggle source
   # File lib/aquarium/utils/name_utils.rb
44 def self.make_valid_object_name type_or_object
45   "#{make_valid_type_name(type_or_object.class)}_#{make_valid_object_id_name(type_or_object.object_id)}"
46 end
make_valid_type_name(type) click to toggle source
   # File lib/aquarium/utils/name_utils.rb
40 def self.make_valid_type_name type
41   type.name.gsub(/:/, '_')
42 end