Class: Ast::Merge::SourceRender::SourceFragment

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

Overview

Exact whole-line range selected from one source revision.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(revision:, start_line:, end_line:, metadata: {}) ⇒ SourceFragment

Returns a new instance of SourceFragment.

Parameters:

  • revision: (Symbol, String)
  • start_line: (Integer)
  • end_line: (Integer)
  • metadata: (Hash[untyped, untyped]) (defaults to: {})


10
11
12
13
14
15
16
17
# File 'lib/ast/merge/source_render/fragment.rb', line 10

def initialize(revision:, start_line:, end_line:, metadata: {})
  @revision = revision.to_sym
  @start_line = Integer(start_line)
  @end_line = Integer(end_line)
  @metadata = .to_h.freeze

  validate!
end

Instance Attribute Details

#end_lineInteger (readonly)

Returns the value of attribute end_line.

Returns:

  • (Integer)


8
9
10
# File 'lib/ast/merge/source_render/fragment.rb', line 8

def end_line
  @end_line
end

#metadataHash[untyped, untyped] (readonly)

Returns the value of attribute metadata.

Returns:

  • (Hash[untyped, untyped])


8
9
10
# File 'lib/ast/merge/source_render/fragment.rb', line 8

def 
  @metadata
end

#revisionSymbol (readonly)

Returns the value of attribute revision.

Returns:

  • (Symbol)


8
9
10
# File 'lib/ast/merge/source_render/fragment.rb', line 8

def revision
  @revision
end

#start_lineInteger (readonly)

Returns the value of attribute start_line.

Returns:

  • (Integer)


8
9
10
# File 'lib/ast/merge/source_render/fragment.rb', line 8

def start_line
  @start_line
end

Instance Method Details

#kind:source

Returns:

  • (:source)


19
20
21
# File 'lib/ast/merge/source_render/fragment.rb', line 19

def kind
  :source
end

#line_rangeRange[Integer]

Returns:

  • (Range[Integer])


23
24
25
# File 'lib/ast/merge/source_render/fragment.rb', line 23

def line_range
  start_line..end_line
end