Dynamically lookup setter methods defined by a instanciated class

Is there any cleaner way than this to get all setter methods of a
instantiated class?

class ABC
attr_accessor :a
attr_accessor :b
attr_accessor :c
attr_reader :d
attr_writer :e
end

abc = ABC.new

puts abc.public_methods.collect! { |m| m if m =~ /[[:alpha:]]=$/
}.delete_if { |m| m.nil? }

require ‘test.rb’
a=
e=
b=
c=
=> true

Thanks.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs