class Attribool::Attribute
Abstraction for an attribute to determine its name, reader, writer, and instance variable name.
Attributes
ivar[R]
The name of the instance variable for the attribute, with the leading “@”.
@return [String]
name[R]
The name of the attribute, without the leading “@”.
@return [String]
reader[R]
The name of the reader for the attribute.
@return [String]
writer[R]
The name of the writer for the attribute.
@return [String]
Public Class Methods
new(attribute, reader_name = nil)
click to toggle source
Create an Attribute
. The attribute can either be a String or a Symbol.
@param [String, Symbol] attribute
@param [String, Symbol, Proc, nil] reader_name
# File lib/attribool/attribute.rb, line 38 def initialize(attribute, reader_name = nil) attribute.to_s.then do |a| @name = a @ivar = "@#{a}" @reader = Attribool::ReaderName.new(name, reader_name).to_s @writer = "#{name}=" end end