Class: Parlour::RbsGenerator::Extend
- Inherits:
-
RbsObject
- Object
- TypedObject
- RbsObject
- Parlour::RbsGenerator::Extend
- Defined in:
- lib/parlour/rbs_generator/extend.rb
Overview
Represents an extend
call.
Instance Attribute Summary collapse
-
#type ⇒ Types::TypeLike
readonly
The type to extend.
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 extend.
- #describe_attrs ⇒ Object
-
#generate_rbs(indent_level, options) ⇒ Array<String>
Generates the RBS lines for this extend.
-
#initialize(generator, type:, &block) ⇒ Extend
constructor
Creates a new
extend
call. -
#merge_into_self(others) ⇒ void
Given an array of Extend instances, merges them into this one.
-
#mergeable?(others) ⇒ Boolean
Given an array of Extend 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, type:, &block) ⇒ Extend
Creates a new extend
call.
16 17 18 19 20 |
# File 'lib/parlour/rbs_generator/extend.rb', line 16 def initialize(generator, type:, &block) super(generator, '') @type = type yield_self(&block) if block end |
Instance Attribute Details
#type ⇒ Types::TypeLike (readonly)
Returns The type to extend.
34 35 36 |
# File 'lib/parlour/rbs_generator/extend.rb', line 34 def type @type end |
Instance Method Details
#==(other) ⇒ Boolean
Returns true if this instance is equal to another extend.
28 29 30 |
# File 'lib/parlour/rbs_generator/extend.rb', line 28 def ==(other) Extend === other && type == other.type end |
#describe_attrs ⇒ Object
84 85 86 |
# File 'lib/parlour/rbs_generator/extend.rb', line 84 def describe_attrs [{type: type}] # avoid quotes end |
#generate_rbs(indent_level, options) ⇒ Array<String>
Generates the RBS lines for this extend.
47 48 49 |
# File 'lib/parlour/rbs_generator/extend.rb', line 47 def generate_rbs(indent_level, ) [.indented(indent_level, "extend #{String === @type ? @type : @type.generate_rbs}")] end |
#merge_into_self(others) ⇒ void
This method returns an undefined value.
Given an array of Parlour::RbsGenerator::Extend instances, merges them into this one. This particular implementation will simply do nothing, as instances are only mergeable if they are indentical. You MUST ensure that #mergeable? is true for those instances.
79 80 81 |
# File 'lib/parlour/rbs_generator/extend.rb', line 79 def merge_into_self(others) # We don't need to change anything! We only merge identical extends end |
#mergeable?(others) ⇒ Boolean
Given an array of Parlour::RbsGenerator::Extend instances, returns true if they may be merged into this instance using #merge_into_self. This is always false.
62 63 64 |
# File 'lib/parlour/rbs_generator/extend.rb', line 62 def mergeable?(others) others.all? { |other| self == other } end |