Class: Flexr::Source::StaticEval

Inherits:
Object
  • Object
show all
Defined in:
lib/flexr/source/static_eval.rb

Constant Summary collapse

MISSING =
Object.new.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, constants: {}, scope: []) ⇒ StaticEval

Returns a new instance of StaticEval.



10
11
12
13
14
# File 'lib/flexr/source/static_eval.rb', line 10

def initialize(source, constants: {}, scope: [])
  @source = source
  @constants = constants
  @scope = Array(scope).map(&:to_s)
end

Instance Attribute Details

#constantsObject (readonly)

Returns the value of attribute constants.



8
9
10
# File 'lib/flexr/source/static_eval.rb', line 8

def constants
  @constants
end

Instance Method Details

#call(node) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/flexr/source/static_eval.rb', line 16

def call(node)
  evaluate(node)
rescue StaticResolutionError
  raise
rescue StandardError => e
  raise_resolution("#{node.class}: #{e.message}")
end