diff options
author | Christoph Helma <helma@in-silico.ch> | 2012-06-28 14:29:12 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2012-06-28 14:29:12 +0200 |
commit | acc59960aa714f31cda12fd07510e48ed04727ee (patch) | |
tree | 0a6f896ab9221e004b4062c3ab4f849337811dd2 /lib/overwrite.rb | |
parent | 5ecdec2682ac6b61912afe74123b6d3d7c15e771 (diff) | |
parent | 9119cb4f3fbcedb5c233b0a1f3fe1398fcc0e193 (diff) |
Merge branch 'feature/dataset' of github.com:opentox/opentox-client into feature/dataset
Diffstat (limited to 'lib/overwrite.rb')
-rw-r--r-- | lib/overwrite.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/overwrite.rb b/lib/overwrite.rb index d98769e..fa2128a 100644 --- a/lib/overwrite.rb +++ b/lib/overwrite.rb @@ -1,3 +1,23 @@ +class Object + # An object is blank if it's false, empty, or a whitespace string. + # For example, "", " ", +nil+, [], and {} are all blank. + def blank? + respond_to?(:empty?) ? empty? : !self + end + + def numeric? + true if Float(self) rescue false + end +end + +=begin +module Enumerable + def duplicates + inject({}) {|h,v| h[v] += 1; h}.reject{|k,v| v==1}.keys + end +end +=end + class String def underscore self.gsub(/::/, '/'). |