Class: Parlour::RbsGenerator::Block
- Inherits:
-
Object
- Object
- Parlour::RbsGenerator::Block
- Extended by:
- T::Sig
- Defined in:
- lib/parlour/rbs_generator/block.rb
Overview
Represents a block in a method signature. (This is not an RbsObject because it doesn’t generate a full line.)
Instance Attribute Summary collapse
-
#required ⇒ Boolean
readonly
Whether this block is required.
-
#type ⇒ Types::Proc
readonly
The type of this block.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Returns true if this instance is equal to another method signature.
-
#generate_rbs(options) ⇒ Array<String>
Generates the RBS string for this signature.
-
#initialize(type, required) ⇒ Block
constructor
Creates a new block for a method signature.
Constructor Details
#initialize(type, required) ⇒ Block
Creates a new block for a method signature.
14 15 16 17 |
# File 'lib/parlour/rbs_generator/block.rb', line 14 def initialize(type, required) @type = type @required = required end |
Instance Attribute Details
#required ⇒ Boolean (readonly)
Whether this block is required.
37 38 39 |
# File 'lib/parlour/rbs_generator/block.rb', line 37 def required @required end |
#type ⇒ Types::Proc (readonly)
The type of this block.
32 33 34 |
# File 'lib/parlour/rbs_generator/block.rb', line 32 def type @type end |
Instance Method Details
#==(other) ⇒ Boolean
Returns true if this instance is equal to another method signature.
25 26 27 |
# File 'lib/parlour/rbs_generator/block.rb', line 25 def ==(other) Block === other && type == other.type && required == other.required end |
#generate_rbs(options) ⇒ Array<String>
Generates the RBS string for this signature.
44 45 46 |
# File 'lib/parlour/rbs_generator/block.rb', line 44 def generate_rbs() ["#{required ? '' : '?'}{ #{type.generate_rbs} }"] end |