Easy access to an object‘s "special" class, otherwise known as it‘s metaclass or singleton class.
Easy access to an object‘s "special" class, otherwise known as it‘s metaclass or singleton class.
Like super but skips to a specific ancestor module or class.
class A def x ; 1 ; end end class B < A def x ; 2 ; end end class C < B def x ; superior(A) ; end end C.new.x #=> 1
Boolean conversion for not being nil or false. Other classes may redefine this to suite the particular need.
"abc".to_b #=> true true.to_b #=> true false.to_b #=> false nil.to_b #=> false
Tests to see if something has value. An object is considered to have value if it is not nil? and if it responds to empty?, i snot.
Takes a hash and creates (singleton) attr_accessors for each key.
with_accessor { :x => 1, :y => 2 } @x #=> 1 @y #=> 2 self.x = 3 self.y = 4 self.x #=> 3 self.y #=> 4
Takes a hash and creates (singleton) attr_readers for each key.
with_reader { :x => 1, :y => 2 } @x #=> 1 @y #=> 2 self.x #=> 1 self.y #=> 2