Sha256: 3114d4780b5caacc687a529ba970ff7ea2e9dc6f9a05323e7fa1aa5c1547914d
Contents?: true
Size: 749 Bytes
Versions: 29
Compression:
Stored size: 749 Bytes
Contents
# frozen_string_literal: true class Code class Node class Base10 < Node def initialize(parsed) return if parsed.blank? @whole = parsed.delete(:whole).presence return unless parsed.key?(:exponent) @exponent = Node::Statement.new(parsed.delete(:exponent).presence) end def evaluate(**args) if @exponent && @whole exponent = @exponent.evaluate(**args) if exponent.is_a?(Object::Integer) Object::Integer.new(@whole, exponent) else Object::Decimal.new(@whole, exponent) end elsif @whole Object::Integer.new(@whole.to_i) else Object::Nothing.new end end end end end
Version data entries
29 entries across 29 versions & 1 rubygems