Get new defined instance methods : attr_accessor « Class « Ruby






Get new defined instance methods


#!/usr/bin/env ruby

class Gaits
  attr_accessor :walk, :trot, :canter
end

p Gaits.instance_methods.sort - Object.instance_methods # => ["canter", "canter=", "trot", "trot=", "walk", "walk="]

 








Related examples in the same category

1.Creating Readable and Writable Attributes: use attr_accessor
2.attr_accessor add accessor to a class
3.Use attr_accessor to add a new attribute and set it
4.A logger