Class: Parlour::RbiGenerator::Extend
- Inherits:
-
RbiObject
- Object
- TypedObject
- RbiObject
- Parlour::RbiGenerator::Extend
- Defined in:
- lib/parlour/rbi_generator/extend.rb
Overview
Represents an extend
call.
Instance Attribute Summary
Attributes inherited from RbiObject
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
-
#generalize_from_rbi! ⇒ Object
Nothing to do.
-
#generate_rbi(indent_level, options) ⇒ Array<String>
Generates the RBI lines for this extend.
-
#initialize(generator, name: '', &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, name: '', &block) ⇒ Extend
Creates a new extend
call.
16 17 18 19 |
# File 'lib/parlour/rbi_generator/extend.rb', line 16 def initialize(generator, name: '', &block) super(generator, name) yield_self(&block) if block end |
Instance Method Details
#==(other) ⇒ Boolean
Returns true if this instance is equal to another extend.
27 28 29 |
# File 'lib/parlour/rbi_generator/extend.rb', line 27 def ==(other) Extend === other && name == other.name end |
#describe_attrs ⇒ Object
82 83 84 |
# File 'lib/parlour/rbi_generator/extend.rb', line 82 def describe_attrs [] end |
#generalize_from_rbi! ⇒ Object
Nothing to do
79 |
# File 'lib/parlour/rbi_generator/extend.rb', line 79 def generalize_from_rbi!; end |
#generate_rbi(indent_level, options) ⇒ Array<String>
Generates the RBI lines for this extend.
42 43 44 |
# File 'lib/parlour/rbi_generator/extend.rb', line 42 def generate_rbi(indent_level, ) [.indented(indent_level, "extend #{name}")] end |
#merge_into_self(others) ⇒ void
This method returns an undefined value.
Given an array of Parlour::RbiGenerator::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.
74 75 76 |
# File 'lib/parlour/rbi_generator/extend.rb', line 74 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::RbiGenerator::Extend instances, returns true if they may be merged into this instance using #merge_into_self. This is always false.
57 58 59 |
# File 'lib/parlour/rbi_generator/extend.rb', line 57 def mergeable?(others) others.all? { |other| self == other } end |