Class: Psych::Merge::FreezeNode
- Inherits:
-
Ast::Merge::FreezeNodeBase
- Object
- Ast::Merge::FreezeNodeBase
- Psych::Merge::FreezeNode
- Defined in:
- lib/psych/merge/freeze_node.rb
Overview
Wrapper to represent freeze blocks as first-class nodes in YAML.
A freeze block is a section marked with freeze/unfreeze comment markers that
should be preserved from the destination during merges.
Inherits from Ast::Merge::FreezeNodeBase for shared functionality including
the Location struct, InvalidStructureError, and configurable marker patterns.
Uses the :hash_comment pattern type by default for YAML files.
Constant Summary collapse
- InvalidStructureError =
Inherit InvalidStructureError from base class
Ast::Merge::FreezeNodeBase::InvalidStructureError
- Location =
Inherit Location from base class
Ast::Merge::FreezeNodeBase::Location
Instance Method Summary collapse
-
#initialize(start_line:, end_line:, lines:, start_marker: nil, end_marker: nil, pattern_type: Ast::Merge::FreezeNodeBase::DEFAULT_PATTERN) ⇒ FreezeNode
constructor
A new instance of FreezeNode.
-
#inspect ⇒ String
String representation for debugging.
-
#mapping? ⇒ Boolean
Check if this is a mapping node (always false for FreezeNode).
-
#scalar? ⇒ Boolean
Check if this is a scalar node (always false for FreezeNode).
-
#sequence? ⇒ Boolean
Check if this is a sequence node (always false for FreezeNode).
-
#signature ⇒ Array
Returns a stable signature for this freeze block.
Constructor Details
#initialize(start_line:, end_line:, lines:, start_marker: nil, end_marker: nil, pattern_type: Ast::Merge::FreezeNodeBase::DEFAULT_PATTERN) ⇒ FreezeNode
Returns a new instance of FreezeNode.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/psych/merge/freeze_node.rb', line 33 def initialize(start_line:, end_line:, lines:, start_marker: nil, end_marker: nil, pattern_type: Ast::Merge::FreezeNodeBase::DEFAULT_PATTERN) # Extract lines for the entire block (lines param is all source lines) block_lines = (start_line..end_line).map { |ln| lines[ln - 1] } super( start_line: start_line, end_line: end_line, lines: block_lines, start_marker: start_marker, end_marker: end_marker, pattern_type: pattern_type ) validate_structure! end |
Instance Method Details
#inspect ⇒ String
String representation for debugging
78 79 80 |
# File 'lib/psych/merge/freeze_node.rb', line 78 def inspect "#<#{self.class.name} lines=#{start_line}..#{end_line} content_length=#{slice&.length || 0}>" end |
#mapping? ⇒ Boolean
Check if this is a mapping node (always false for FreezeNode)
60 61 62 |
# File 'lib/psych/merge/freeze_node.rb', line 60 def mapping? false end |
#scalar? ⇒ Boolean
Check if this is a scalar node (always false for FreezeNode)
72 73 74 |
# File 'lib/psych/merge/freeze_node.rb', line 72 def scalar? false end |
#sequence? ⇒ Boolean
Check if this is a sequence node (always false for FreezeNode)
66 67 68 |
# File 'lib/psych/merge/freeze_node.rb', line 66 def sequence? false end |
#signature ⇒ Array
Returns a stable signature for this freeze block.
Signature includes the normalized content to detect changes.
52 53 54 55 56 |
# File 'lib/psych/merge/freeze_node.rb', line 52 def signature # Normalize by stripping each line and joining normalized = @lines.map { |l| l&.strip }.compact.reject(&:empty?).join("\n") [:FreezeNode, normalized] end |