Sha256: 810b0e02525b1bebe69f2a0ec9787a3bdb7f4852c4ccb02ea456761c00861166
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
# encoding: utf-8 # Object class Object # Check boolean type # # boolean? true # => true # boolean? false # => true # boolean? nil # => false # boolean? 'true' # => false # boolean? 'false' # => false # boolean? '' # => false def boolean? self.is_a?(TrueClass) || self.is_a?(FalseClass) end # Get self define methods. # # class SampleClass < String # def public_hello # "public hello" # end # # protected # # def protected_hello # "protected hello" # end # # private # # def private_hello # "private hello" # end # end # # SampleClass.new.my_methods # => [:public_hello, :protected_hello, :private_hello] def my_methods public_methods(false) + protected_methods(false) + private_methods(false) end # If self match any one of args, return true. # # "hoge".any_of? %w{hoge hige} # => true # "hige".any_of? %w{hoge hige} # => true # "hege".any_of? %w{hoge hige} # => false def any_of?(*args) args.each {|value|return true if self == value} false end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tbpgr_utils-0.0.9 | lib/open_classes/object.rb |
tbpgr_utils-0.0.8 | lib/open_classes/object.rb |
tbpgr_utils-0.0.7 | lib/open_classes/object.rb |