Class: Attribool::Attribute
- Inherits:
- 
      Object
      
        - Object
- Attribool::Attribute
 
- Defined in:
- lib/attribool/attribute.rb
Overview
Abstraction for an attribute to determine its name, reader, writer, and instance variable name.
Instance Attribute Summary collapse
- 
  
    
      #ivar  ⇒ String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The name of the instance variable for the attribute, with the leading “@”. 
- 
  
    
      #name  ⇒ String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The name of the attribute, without the leading “@”. 
- 
  
    
      #reader  ⇒ String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The name of the reader for the attribute. 
- 
  
    
      #writer  ⇒ String 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    The name of the writer for the attribute. 
Instance Method Summary collapse
- 
  
    
      #initialize(attribute, reader_name = nil)  ⇒ Attribute 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Create an Attribute. 
Constructor Details
#initialize(attribute, reader_name = nil) ⇒ Attribute
Create an Attribute. The attribute can either be a String or a Symbol.
| 38 39 40 41 42 43 44 45 | # 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 | 
Instance Attribute Details
#ivar ⇒ String (readonly)
The name of the instance variable for the attribute, with the leading “@”.
| 18 19 20 | # File 'lib/attribool/attribute.rb', line 18 def ivar @ivar end | 
#name ⇒ String (readonly)
The name of the attribute, without the leading “@”.
| 12 13 14 | # File 'lib/attribool/attribute.rb', line 12 def name @name end | 
#reader ⇒ String (readonly)
The name of the reader for the attribute.
| 24 25 26 | # File 'lib/attribool/attribute.rb', line 24 def reader @reader end | 
#writer ⇒ String (readonly)
The name of the writer for the attribute.
| 30 31 32 | # File 'lib/attribool/attribute.rb', line 30 def writer @writer end |