Class: Ast::Merge::Runtime::Surface

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

Overview

Value object describing one owned merge surface.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(surface_kind:, address:, declared_language: nil, effective_language: nil, parent_address: nil, span: nil, reconstruction_strategy: nil, metadata: {}) ⇒ Surface

Returns a new instance of Surface.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ast/merge/runtime/surface.rb', line 17

def initialize(
  surface_kind:,
  address:, declared_language: nil,
  effective_language: nil,
  parent_address: nil,
  span: nil,
  reconstruction_strategy: nil,
  metadata: {}
)
  @surface_kind = surface_kind&.to_sym
  @declared_language = normalize_language(declared_language)
  @effective_language = normalize_language(effective_language)
  @address = address.to_s
  @parent_address = parent_address&.to_s
  @span = span
  @reconstruction_strategy = reconstruction_strategy&.to_sym
  @metadata = .dup.freeze
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



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

def address
  @address
end

#declared_languageObject (readonly)

Returns the value of attribute declared_language.



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

def declared_language
  @declared_language
end

#effective_languageObject (readonly)

Returns the value of attribute effective_language.



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

def effective_language
  @effective_language
end

#metadataObject (readonly)

Returns the value of attribute metadata.



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

def 
  @metadata
end

#parent_addressObject (readonly)

Returns the value of attribute parent_address.



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

def parent_address
  @parent_address
end

#reconstruction_strategyObject (readonly)

Returns the value of attribute reconstruction_strategy.



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

def reconstruction_strategy
  @reconstruction_strategy
end

#spanObject (readonly)

Returns the value of attribute span.



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

def span
  @span
end

#surface_kindObject (readonly)

Returns the value of attribute surface_kind.



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

def surface_kind
  @surface_kind
end

Instance Method Details

#embedded?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/ast/merge/runtime/surface.rb', line 36

def embedded?
  !parent_address.nil?
end

#root?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/ast/merge/runtime/surface.rb', line 40

def root?
  !embedded?
end

#to_hObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ast/merge/runtime/surface.rb', line 44

def to_h
  {
    surface_kind: surface_kind,
    declared_language: declared_language,
    effective_language: effective_language,
    address: address,
    parent_address: parent_address,
    span: span,
    reconstruction_strategy: reconstruction_strategy,
    metadata: ,
    embedded: embedded?
  }.compact
end