-
Notifications
You must be signed in to change notification settings - Fork 6
factories
-
Is a missing value unset? or nil?
-
(Boolean)
-
String Symbol
-
Regexp
-
Bignum Integer Numeric
-
Float (Double)
-
Complex Rational
-
Random
-
Time
-
Date
-
Dir File Pathname
-
Whatever -- alias for IdentityFactory
-
Method, Proc
-
Range
-
Hash
-
Array
-
Object
-
Class Module FalseClass TrueClass NilClass
These don't have factories because I can't really think of a reasonable use case
- DateTime Struct MatchData UnboundMethod IO Enumerator Fixnum Object File::Stat StringIO
These are not decorated because it's not a good idea
-
BasicObject
-
Exception Interrupt SignalException SystemExit
-
Encoding Data Fiber Mutex ThreadGroup Thread Binding Queue
:Integer, Fixnum, :to_i, :to_i, is_a?(Float), nil nil, err, err :Bignum :Float, Float, :to_f, :to_f, is_a?(Fixnum), nil nil, err, err :Complex :Rational
:String, String, :to_s, :to_s, is_a?(String), nil, "", ??, ?? :Binary, Binary, :to_s, :to_s, is_a?(String), nil, "", ??, ?? :Symbol, Symbol, :to_s, :to_s, is_a?(String), nil, nil, ??, ?? :Regexp, :Time
:Identity :Whatever
:Class :Module :TrueClass, true, :FalseClass, false, :NilClass, nil, :Boolean, [true,false], ??, [true, false], [true, false], nil, nil, ??, ??
:Hash :Array :Range :Set
:Method :Proc
INTERNAL_CLASSES_RE = /(^(Encoding|Struct|Gem)|Error\b|Errno|#<|fatal)/) ADDABLE_CLASSES = [Identity, Whatever, Itself, Boolean, Long, Double, Pathname, Set] INTERESTING_CLASSES = [String, Symbol, Regexp, Integer, Bignum, Float, Numeric, Complex, Rational, Time, Date, Dir, File, Hash, Array, Range, Method, Proc, Random, Class, Module, NilClass, TrueClass, FalseClass, ] BORING_CLASSES = [Object, File::Stat, StringIO, DateTime, Struct, MatchData, UnboundMethod, IO, Enumerator, Fixnum, BasicObject, Exception, Interrupt, SignalException, SystemExit, Encoding, Data, Fiber, Mutex, ThreadGroup, Thread, Binding, ]
ObjectSpace.each_object(Class). reject{|kl| (kl.to_s =~ INTERNAL_CLASSES_RE }.map(&:to_s).sort - (ADDED_CLASSES + INTERESTING_CLASSES + BORING_CLASSES)
[:to_ary, :to_io, :to_str, :to_hash, :to_sym, :to_path, :to_proc, :to_int, :to_f, :to_a, :to_r, :to_c, :to_i, :to_s, :to_enum]