class Foo BAR = 0x01 BAZ = 0x02 attr_accessor :state def frobify # ?? end def to_s "state: #{frobify( @state )}" end end f = Foo.new f.state = Foo::BAR puts f # This should output # state: Foo::BAR # orĀ· # state: BAR