In Files

  • mrblib/class.rb

Module

Public Instance Methods

attr(name) click to toggle source

15.2.2.4.11

 
               # File mrblib/class.rb, line 29
def attr(name)
  attr_reader(name)
end
            
attr_accessor(*names) click to toggle source

15.2.2.4.12

 
               # File mrblib/class.rb, line 24
def attr_accessor(*names)
  attr_reader(*names)
  attr_writer(*names)
end
            
attr_reader(*names) click to toggle source

15.2.2.4.13

 
               # File mrblib/class.rb, line 3
def attr_reader(*names)
  names.each do |name|
    name = name.to_s
    raise(NameError, "#{name.inspect} is not allowed as an instance variable name") if name.include?('@') || name.include?('?')  || name.include?('$')

    attr_name = '@'+name
    define_method(name){self.instance_variable_get(attr_name)}
  end
end
            
attr_writer(*names) click to toggle source

15.2.2.4.14

 
               # File mrblib/class.rb, line 13
def attr_writer(*names)
  names.each do |name|
    name = name.to_s
    raise(NameError, "#{name.inspect} is not allowed as an instance variable name") if name.include?('@') || name.include?('?')  || name.include?('$')

    attr_name = '@'+name
    name = (name+"=").intern
    define_method(name){|v|self.instance_variable_set(attr_name,v)}
  end
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus