Class: Fort::Type::Base
- Inherits:
- 
      Object
      
        - Object
- Fort::Type::Base
 
- Extended by:
- Providable
- Defined in:
- lib/fort/type.rb
Constant Summary
Constants included from Providable
Instance Attribute Summary collapse
- 
  
    
      #dim  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute dim. 
- 
  
    
      #id  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute id. 
- 
  
    
      #type  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute type. 
Instance Method Summary collapse
- #declare ⇒ Object
- #dimension ⇒ Object
- 
  
    
      #initialize(id, params = {})  ⇒ Base 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Base. 
- #parenthesis ⇒ Object
- #to_s ⇒ Object
Methods included from Providable
Constructor Details
#initialize(id, params = {}) ⇒ Base
Returns a new instance of Base.
| 40 41 42 43 44 45 | # File 'lib/fort/type.rb', line 40 def initialize(id, params = {}) @id = id @dim = params.fetch(:dim) raise ArgumentError, "@dim: #{@dim}" if @dim < 0 @type = self.class.to_s.split('::').last.to_sym end | 
Instance Attribute Details
#dim ⇒ Object (readonly)
Returns the value of attribute dim.
| 46 47 48 | # File 'lib/fort/type.rb', line 46 def dim @dim end | 
#id ⇒ Object (readonly)
Returns the value of attribute id.
| 46 47 48 | # File 'lib/fort/type.rb', line 46 def id @id end | 
#type ⇒ Object (readonly)
Returns the value of attribute type.
| 46 47 48 | # File 'lib/fort/type.rb', line 46 def type @type end | 
Instance Method Details
#declare ⇒ Object
| 52 53 54 | # File 'lib/fort/type.rb', line 52 def declare "#{@type}#{dimension()}" end | 
#dimension ⇒ Object
| 64 65 66 67 68 69 70 | # File 'lib/fort/type.rb', line 64 def dimension if @dim >= 1 ", dimension" + parenthesis() else '' end end | 
#parenthesis ⇒ Object
| 56 57 58 59 60 61 62 | # File 'lib/fort/type.rb', line 56 def parenthesis if @dim >= 1 "(" + colons() + ")" else '' end end | 
#to_s ⇒ Object
| 48 49 50 | # File 'lib/fort/type.rb', line 48 def to_s "#{@type}Dim#{@dim}" end |