Sha256: 588cf6888c93595eb7847d9ea5a85e770524b6e5d0feb23161a90f009756f50b
Contents?: true
Size: 847 Bytes
Versions: 21
Compression:
Stored size: 847 Bytes
Contents
class Code class Node class Equal < Node def initialize(parsed) @operator = parsed.delete(:operator) @left = parsed.delete(:left) @right = Node::Statement.new(parsed.delete(:right)) super(parsed) end def evaluate(**args) right = @right.evaluate(**args) left = ::Code::Object::String.new(@left) context = args.fetch(:context) if @operator == "" context[left] = right else if context[left].nil? raise ::Code::Error::Undefined.new("#{left} is not defined") end context[left] = context.fetch(left).call( operator: @operator, arguments: [::Code::Object::Argument.new(right)], **args ) end args[:context][left] end end end end
Version data entries
21 entries across 21 versions & 3 rubygems