Class: Ast::Merge::Runtime::Frame

Inherits:
Object
  • Object
show all
Defined in:
lib/ast/merge/runtime/frame.rb

Overview

One stack frame in a nested merge session.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation_id:, depth:, surface_path:, parent_operation_id: nil, language_chain: []) ⇒ Frame

Returns a new instance of Frame.



14
15
16
17
18
19
20
21
22
# File 'lib/ast/merge/runtime/frame.rb', line 14

def initialize(operation_id:, depth:, surface_path:, parent_operation_id: nil, language_chain: [])
  @parent_operation_id = parent_operation_id
  @operation_id = operation_id
  @depth = Integer(depth)
  @surface_path = surface_path.to_s
  @language_chain = Array(language_chain).map do |language|
    language.to_s.strip.downcase.tr('-', '_').to_sym
  end.freeze
end

Instance Attribute Details

#depthObject (readonly)

Returns the value of attribute depth.



8
9
10
# File 'lib/ast/merge/runtime/frame.rb', line 8

def depth
  @depth
end

#language_chainObject (readonly)

Returns the value of attribute language_chain.



8
9
10
# File 'lib/ast/merge/runtime/frame.rb', line 8

def language_chain
  @language_chain
end

#operation_idObject (readonly)

Returns the value of attribute operation_id.



8
9
10
# File 'lib/ast/merge/runtime/frame.rb', line 8

def operation_id
  @operation_id
end

#parent_operation_idObject (readonly)

Returns the value of attribute parent_operation_id.



8
9
10
# File 'lib/ast/merge/runtime/frame.rb', line 8

def parent_operation_id
  @parent_operation_id
end

#surface_pathObject (readonly)

Returns the value of attribute surface_path.



8
9
10
# File 'lib/ast/merge/runtime/frame.rb', line 8

def surface_path
  @surface_path
end

Instance Method Details

#root?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ast/merge/runtime/frame.rb', line 24

def root?
  parent_operation_id.nil?
end

#to_hObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/ast/merge/runtime/frame.rb', line 28

def to_h
  {
    parent_operation_id: parent_operation_id,
    operation_id: operation_id,
    depth: depth,
    surface_path: surface_path,
    language_chain: language_chain,
    root: root?
  }
end