Class: Ast::Merge::Comment::Empty
- Defined in:
- lib/ast/merge/comment/empty.rb
Overview
Represents an empty/blank line in source code.
Empty lines are important for preserving document structure and separating comment blocks. They serve as natural boundaries between logical sections of comments.
Instance Attribute Summary collapse
-
#line_number ⇒ Integer
readonly
The line number in source.
-
#text ⇒ String
readonly
The actual line content (may have whitespace).
Attributes inherited from AstNode
Instance Method Summary collapse
-
#freeze_marker?(_freeze_token) ⇒ Boolean
Empty lines never contain freeze markers.
-
#initialize(line_number:, text: "") ⇒ Empty
constructor
Initialize a new Empty line.
-
#inspect ⇒ String
Human-readable representation.
-
#normalized_content ⇒ String
Empty normalized content.
-
#signature ⇒ Array
Empty lines have a generic signature - they don’t match by content.
Methods inherited from AstNode
#children, #respond_to_missing?, #to_s, #unwrap
Constructor Details
#initialize(line_number:, text: "") ⇒ Empty
Initialize a new Empty line.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ast/merge/comment/empty.rb', line 35 def initialize(line_number:, text: "") @line_number = line_number @text = text.to_s location = AstNode::Location.new( start_line: line_number, end_line: line_number, start_column: 0, end_column: @text.length, ) super(slice: @text, location: location) end |
Instance Attribute Details
#line_number ⇒ Integer (readonly)
Returns The line number in source.
26 27 28 |
# File 'lib/ast/merge/comment/empty.rb', line 26 def line_number @line_number end |
#text ⇒ String (readonly)
Returns The actual line content (may have whitespace).
29 30 31 |
# File 'lib/ast/merge/comment/empty.rb', line 29 def text @text end |
Instance Method Details
#freeze_marker?(_freeze_token) ⇒ Boolean
Empty lines never contain freeze markers.
67 68 69 |
# File 'lib/ast/merge/comment/empty.rb', line 67 def freeze_marker?(_freeze_token) false end |
#inspect ⇒ String
Returns Human-readable representation.
72 73 74 |
# File 'lib/ast/merge/comment/empty.rb', line 72 def inspect "#<Comment::Empty line=#{line_number}>" end |
#normalized_content ⇒ String
Returns Empty normalized content.
59 60 61 |
# File 'lib/ast/merge/comment/empty.rb', line 59 def normalized_content "" end |
#signature ⇒ Array
Empty lines have a generic signature - they don’t match by content.
All empty lines are considered equivalent for matching purposes.
54 55 56 |
# File 'lib/ast/merge/comment/empty.rb', line 54 def signature [:empty_line] end |