Class: Ast::Merge::Layout::Attachment
- Inherits:
-
Object
- Object
- Ast::Merge::Layout::Attachment
- Defined in:
- lib/ast/merge/layout/attachment.rb
Overview
Passive per-owner container for adjacent blank-line gaps.
An attachment can reference a leading gap, a trailing gap, or both. The same shared gap object may appear in attachments for adjacent owners.
Instance Attribute Summary collapse
-
#leading_gap ⇒ Object
readonly
Returns the value of attribute leading_gap.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#trailing_gap ⇒ Object
readonly
Returns the value of attribute trailing_gap.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#gaps ⇒ Array<Gap>
Return all distinct gaps referenced by this attachment.
-
#initialize(owner: nil, leading_gap: nil, trailing_gap: nil, metadata: {}, **options) ⇒ Attachment
constructor
A new instance of Attachment.
-
#inspect ⇒ String
Return a concise debug representation of the attachment.
- #leading_controls_output?(**options) ⇒ Boolean
- #trailing_controls_output?(**options) ⇒ Boolean
Constructor Details
#initialize(owner: nil, leading_gap: nil, trailing_gap: nil, metadata: {}, **options) ⇒ Attachment
Returns a new instance of Attachment.
13 14 15 16 17 18 |
# File 'lib/ast/merge/layout/attachment.rb', line 13 def initialize(owner: nil, leading_gap: nil, trailing_gap: nil, metadata: {}, **) @owner = owner @leading_gap = leading_gap @trailing_gap = trailing_gap @metadata = .merge().freeze end |
Instance Attribute Details
#leading_gap ⇒ Object (readonly)
Returns the value of attribute leading_gap.
11 12 13 |
# File 'lib/ast/merge/layout/attachment.rb', line 11 def leading_gap @leading_gap end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
11 12 13 |
# File 'lib/ast/merge/layout/attachment.rb', line 11 def @metadata end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
11 12 13 |
# File 'lib/ast/merge/layout/attachment.rb', line 11 def owner @owner end |
#trailing_gap ⇒ Object (readonly)
Returns the value of attribute trailing_gap.
11 12 13 |
# File 'lib/ast/merge/layout/attachment.rb', line 11 def trailing_gap @trailing_gap end |
Instance Method Details
#empty? ⇒ Boolean
27 28 29 |
# File 'lib/ast/merge/layout/attachment.rb', line 27 def empty? gaps.empty? end |
#gaps ⇒ Array<Gap>
Return all distinct gaps referenced by this attachment.
23 24 25 |
# File 'lib/ast/merge/layout/attachment.rb', line 23 def gaps [leading_gap, trailing_gap].compact.uniq end |
#inspect ⇒ String
Return a concise debug representation of the attachment.
42 43 44 |
# File 'lib/ast/merge/layout/attachment.rb', line 42 def inspect "#<#{self.class.name} owner=#{owner&.class&.name} gaps=#{gaps.size}>" end |
#leading_controls_output?(**options) ⇒ Boolean
31 32 33 |
# File 'lib/ast/merge/layout/attachment.rb', line 31 def leading_controls_output?(**) leading_gap&.controls_output_for?(owner, **) || false end |
#trailing_controls_output?(**options) ⇒ Boolean
35 36 37 |
# File 'lib/ast/merge/layout/attachment.rb', line 35 def trailing_controls_output?(**) trailing_gap&.controls_output_for?(owner, **) || false end |