Class: Ast::Merge::SourceRender::ConflictFragment

Inherits:
Object
  • Object
show all
Defined in:
lib/ast/merge/source_render/fragment.rb,
sig/ast/merge.rbs

Overview

Localized base/ours/theirs alternatives selected by a provider.

Constant Summary collapse

DEFAULT_MARKER_SIZE =

Returns:

  • (Integer)
7

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conflict_id:, base:, ours:, theirs:, labels: {}, marker_size: DEFAULT_MARKER_SIZE, metadata: {}) ⇒ ConflictFragment

rubocop:disable Metrics/ParameterLists -- three semantic sides are explicit contract roles

Parameters:



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ast/merge/source_render/fragment.rb', line 70

def initialize(conflict_id:, base:, ours:, theirs:, labels: {}, marker_size: DEFAULT_MARKER_SIZE, metadata: {})
  @conflict_id = conflict_id.to_s.freeze
  @base = normalize_children(base)
  @ours = normalize_children(ours)
  @theirs = normalize_children(theirs)
  @labels = default_labels.merge(symbolize_keys(labels)).freeze
  @marker_size = Integer(marker_size)
  @metadata = .to_h.freeze

  validate!
end

Instance Attribute Details

#baseArray[SourceFragment | SynthesizedFragment] (readonly)

Returns the value of attribute base.

Returns:



67
68
69
# File 'lib/ast/merge/source_render/fragment.rb', line 67

def base
  @base
end

#conflict_idString (readonly)

Returns the value of attribute conflict_id.

Returns:

  • (String)


67
68
69
# File 'lib/ast/merge/source_render/fragment.rb', line 67

def conflict_id
  @conflict_id
end

#labelsHash[Symbol, String] (readonly)

Returns the value of attribute labels.

Returns:

  • (Hash[Symbol, String])


67
68
69
# File 'lib/ast/merge/source_render/fragment.rb', line 67

def labels
  @labels
end

#marker_sizeInteger (readonly)

Returns the value of attribute marker_size.

Returns:

  • (Integer)


67
68
69
# File 'lib/ast/merge/source_render/fragment.rb', line 67

def marker_size
  @marker_size
end

#metadataHash[untyped, untyped] (readonly)

Returns the value of attribute metadata.

Returns:

  • (Hash[untyped, untyped])


67
68
69
# File 'lib/ast/merge/source_render/fragment.rb', line 67

def 
  @metadata
end

#oursArray[SourceFragment | SynthesizedFragment] (readonly)

Returns the value of attribute ours.

Returns:



67
68
69
# File 'lib/ast/merge/source_render/fragment.rb', line 67

def ours
  @ours
end

#theirsArray[SourceFragment | SynthesizedFragment] (readonly)

Returns the value of attribute theirs.

Returns:



67
68
69
# File 'lib/ast/merge/source_render/fragment.rb', line 67

def theirs
  @theirs
end

Instance Method Details

#children_for(side) ⇒ Array[SourceFragment | SynthesizedFragment]

Parameters:

  • side (:base, :ours, :theirs)

Returns:



87
88
89
# File 'lib/ast/merge/source_render/fragment.rb', line 87

def children_for(side)
  public_send(side)
end

#kind:conflict

rubocop:enable Metrics/ParameterLists

Returns:

  • (:conflict)


83
84
85
# File 'lib/ast/merge/source_render/fragment.rb', line 83

def kind
  :conflict
end