Class: Parlour::RbsGenerator::Arbitrary
- Inherits:
 - 
      RbsObject
      
        
- Object
 - TypedObject
 - RbsObject
 - Parlour::RbsGenerator::Arbitrary
 
 
- Defined in:
 - lib/parlour/rbs_generator/arbitrary.rb
 
Overview
Represents miscellaneous Ruby code.
Instance Attribute Summary collapse
- 
  
    
      #code  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns arbitrary code string.
 
Attributes inherited from RbsObject
Attributes inherited from TypedObject
#comments, #generated_by, #name
Instance Method Summary collapse
- 
  
    
      #==(other)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Returns true if this instance is equal to another arbitrary code line.
 - #describe_attrs ⇒ Object
 - 
  
    
      #generate_rbs(indent_level, options)  ⇒ Array<String> 
    
    
  
  
  
  
  
  
  
  
  
    
Generates the RBS lines for this arbitrary code.
 - 
  
    
      #initialize(generator, code: '', &block)  ⇒ Arbitrary 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Creates new arbitrary code.
 - 
  
    
      #merge_into_self(others)  ⇒ void 
    
    
  
  
  
  
  
  
  
  
  
    
Given an array of Arbitrary instances, merges them into this one.
 - 
  
    
      #mergeable?(others)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Given an array of Arbitrary instances, returns true if they may be merged into this instance using #merge_into_self.
 
Methods inherited from TypedObject
#add_comment, #describe, #describe_tree
Constructor Details
#initialize(generator, code: '', &block) ⇒ Arbitrary
Creates new arbitrary code.
      17 18 19 20 21  | 
    
      # File 'lib/parlour/rbs_generator/arbitrary.rb', line 17 def initialize(generator, code: '', &block) super(generator, '') @code = code yield_self(&block) if block end  | 
  
Instance Attribute Details
#code ⇒ Object
Returns arbitrary code string.
      25 26 27  | 
    
      # File 'lib/parlour/rbs_generator/arbitrary.rb', line 25 def code @code end  | 
  
Instance Method Details
#==(other) ⇒ Boolean
Returns true if this instance is equal to another arbitrary code line.
      33 34 35  | 
    
      # File 'lib/parlour/rbs_generator/arbitrary.rb', line 33 def ==(other) Arbitrary === other && code == other.code end  | 
  
#describe_attrs ⇒ Object
      84 85 86  | 
    
      # File 'lib/parlour/rbs_generator/arbitrary.rb', line 84 def describe_attrs [:code] end  | 
  
#generate_rbs(indent_level, options) ⇒ Array<String>
Generates the RBS lines for this arbitrary code.
      48 49 50  | 
    
      # File 'lib/parlour/rbs_generator/arbitrary.rb', line 48 def generate_rbs(indent_level, ) code.split("\n").map { |l| .indented(indent_level, l) } end  | 
  
#merge_into_self(others) ⇒ void
This method returns an undefined value.
Given an array of Parlour::RbsGenerator::Arbitrary instances, merges them into this one. This particular implementation always throws an exception, because #mergeable? is always false.
      79 80 81  | 
    
      # File 'lib/parlour/rbs_generator/arbitrary.rb', line 79 def merge_into_self(others) raise 'arbitrary code is never mergeable' end  | 
  
#mergeable?(others) ⇒ Boolean
Given an array of Parlour::RbsGenerator::Arbitrary instances, returns true if they may be merged into this instance using #merge_into_self. This is always false.
      63 64 65  | 
    
      # File 'lib/parlour/rbs_generator/arbitrary.rb', line 63 def mergeable?(others) false end  |