Object (Class)

In: basiclibrary.rb
Parent: Object

Extensions to the Object class

Methods

Public Instance methods

Perform a deep clone on the object (where Object#clone performs a shallow clone)

(Found on ruby-talk, forgot to include proper credit to the author; sorry)

indent — the tab indentation level to start at

Produces similar output to inspect, but with nice hierarchical indentation for items stored in Hashes or Arrays

  h = { :name=>'Gavin Kistner', 'age'=>31, :cars=>['Jeep','Passat'],
        "cats"=>[ {:name=>'Phleep', :weight=>15 }, {:name=>'Tessa', :weight=>7} ] }

  puts h.inspect
  #=> {:cars=>["Jeep", "Passat"], :name=>"Gavin Kistner", "cats"=>[{:weight=>15, :name=>"Phleep"}, {:weight=>7, :name=>"Tessa"}], "age"=>31}

  puts h.hier_inspect
  #=> {
  #=>       :cars => [
  #=>               "Jeep",
  #=>               "Passat"
  #=>       ],
  #=>       :name => "Gavin Kistner",
  #=>       "cats" => [
  #=>               {
  #=>                       :weight => 15,
  #=>                       :name => "Phleep"
  #=>               },
  #=>               {
  #=>                       :weight => 7,
  #=>                       :name => "Tessa"
  #=>               }
  #=>       ],
  #=>       "age" => 31
  #=> }

[Validate]