Sha256: c9cb24c28654a082a4f9de5729f5da8455ba9d285aead65f4b5b7dcdd8a82626
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
class Hash begin method "to_options" rescue def to_options inject(Hash.new){|h, kv| h.update kv.first.to_s.to_sym => kv.last} end def to_options! replace to_options end end begin method "to_string_options" rescue def to_string_options inject(Hash.new){|h, kv| h.update kv.first.to_s => kv.last} end def to_string_options! replace to_string_options end end begin method "reverse_merge" rescue def reverse_merge other other.merge self end def reverse_merge! other replace reverse_merge(other) end end end class Object begin method "returning" rescue def returning value, &block block.call value value end end end class Object def singleton_class &block @singleton_class ||= class << self self end block ? @singleton_class.module_eval(&block) : @singleton_class end end class Module Instance_Methods = instance_method "instance_methods" unless defined? Instance_Methods def instance_methods &block block ? module_eval(&block) : Instance_Methods.bind(self).call end def module_methods &block block ? singleton_class(&block) : singleton_methods end alias_method "class_methods", "module_methods" end class String begin method 'underscore' rescue def underscore gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bj-0.0.1 | lib/bj/stdext.rb |
bj-0.0.2 | lib/bj/stdext.rb |