Class: Ast::Merge::SourceRender::Plan
- Inherits:
-
Object
- Object
- Ast::Merge::SourceRender::Plan
- Defined in:
- lib/ast/merge/source_render/plan.rb,
sig/ast/merge.rbs
Overview
Passive ordered render plan produced by a family provider.
Instance Attribute Summary collapse
-
#fragments ⇒ Array[fragment]
readonly
Returns the value of attribute fragments.
-
#metadata ⇒ Hash[untyped, untyped]
readonly
Returns the value of attribute metadata.
-
#sources ⇒ Hash[Symbol, String]
readonly
Returns the value of attribute sources.
Instance Method Summary collapse
-
#initialize(sources:, fragments:, metadata: {}) ⇒ Plan
constructor
A new instance of Plan.
- #source_content(fragment) ⇒ String
- #source_lines(revision) ⇒ Array[String]
Constructor Details
#initialize(sources:, fragments:, metadata: {}) ⇒ Plan
Returns a new instance of Plan.
10 11 12 13 14 15 16 |
# File 'lib/ast/merge/source_render/plan.rb', line 10 def initialize(sources:, fragments:, metadata: {}) @sources = normalize_sources(sources) @fragments = Array(fragments).freeze @metadata = .to_h.freeze validate! end |
Instance Attribute Details
#fragments ⇒ Array[fragment] (readonly)
Returns the value of attribute fragments.
8 9 10 |
# File 'lib/ast/merge/source_render/plan.rb', line 8 def fragments @fragments end |
#metadata ⇒ Hash[untyped, untyped] (readonly)
Returns the value of attribute metadata.
8 9 10 |
# File 'lib/ast/merge/source_render/plan.rb', line 8 def @metadata end |
#sources ⇒ Hash[Symbol, String] (readonly)
Returns the value of attribute sources.
8 9 10 |
# File 'lib/ast/merge/source_render/plan.rb', line 8 def sources @sources end |
Instance Method Details
#source_content(fragment) ⇒ String
22 23 24 |
# File 'lib/ast/merge/source_render/plan.rb', line 22 def source_content(fragment) source_lines(fragment.revision)[(fragment.start_line - 1)..(fragment.end_line - 1)].join end |
#source_lines(revision) ⇒ Array[String]
18 19 20 |
# File 'lib/ast/merge/source_render/plan.rb', line 18 def source_lines(revision) sources.fetch(revision.to_sym).lines end |