Class: Parlour::RbiGenerator::Include
- Inherits:
-
RbiObject
- Object
- TypedObject
- RbiObject
- Parlour::RbiGenerator::Include
- Defined in:
- lib/parlour/rbi_generator/include.rb
Overview
Represents an include
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 include.
- #describe_attrs ⇒ Object
-
#generalize_from_rbi! ⇒ Object
Nothing to do.
-
#generate_rbi(indent_level, options) ⇒ Array<String>
Generates the RBI lines for this include.
-
#initialize(generator, name: '', &block) ⇒ Include
constructor
Creates a new
include
call. -
#merge_into_self(others) ⇒ void
Given an array of Include instances, merges them into this one.
-
#mergeable?(others) ⇒ Boolean
Given an array of Include 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) ⇒ Include
Creates a new include
call.
16 17 18 19 |
# File 'lib/parlour/rbi_generator/include.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 include.
27 28 29 |
# File 'lib/parlour/rbi_generator/include.rb', line 27 def ==(other) Include === other && name == other.name end |
#describe_attrs ⇒ Object
82 83 84 |
# File 'lib/parlour/rbi_generator/include.rb', line 82 def describe_attrs [] end |
#generalize_from_rbi! ⇒ Object
Nothing to do
79 |
# File 'lib/parlour/rbi_generator/include.rb', line 79 def generalize_from_rbi!; end |
#generate_rbi(indent_level, options) ⇒ Array<String>
Generates the RBI lines for this include.
42 43 44 |
# File 'lib/parlour/rbi_generator/include.rb', line 42 def generate_rbi(indent_level, ) [.indented(indent_level, "include #{name}")] end |
#merge_into_self(others) ⇒ void
This method returns an undefined value.
Given an array of Parlour::RbiGenerator::Include 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/include.rb', line 74 def merge_into_self(others) # We don't need to change anything! We only merge identical includes end |
#mergeable?(others) ⇒ Boolean
Given an array of Parlour::RbiGenerator::Include 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/include.rb', line 57 def mergeable?(others) others.all? { |other| self == other } end |