Sha256: b706d42c417fa09c630561b67885f65a47690f61e0e1578cca0a6d1636e1bf25

Contents?: true

Size: 776 Bytes

Versions: 33

Compression:

Stored size: 776 Bytes

Contents

# frozen_string_literal: true

class Code
  class Node
    class Number < Node
      def initialize(parsed)
        return if parsed.blank?

        if parsed.key?(:decimal)
          @statement = Node::Decimal.new(parsed.delete(:decimal))
        elsif parsed.key?(:base_16)
          @statement = Node::Base16.new(parsed.delete(:base_16))
        elsif parsed.key?(:base_10)
          @statement = Node::Base10.new(parsed.delete(:base_10))
        elsif parsed.key?(:base_8)
          @statement = Node::Base8.new(parsed.delete(:base_8))
        elsif parsed.key?(:base_2)
          @statement = Node::Base2.new(parsed.delete(:base_2))
        end
      end

      def evaluate(**args)
        @statement&.evaluate(**args) || Object::Nothing.new
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
code-ruby-1.1.3 lib/code/node/number.rb
code-ruby-1.1.1 lib/code/node/number.rb
code-ruby-1.1.0 lib/code/node/number.rb
code-ruby-1.0.0 lib/code/node/number.rb
code-ruby-0.15.16 lib/code/node/number.rb
code-ruby-0.15.15 lib/code/node/number.rb
code-ruby-0.15.14 lib/code/node/number.rb
code-ruby-0.15.13 lib/code/node/number.rb
code-ruby-0.15.12 lib/code/node/number.rb
code-ruby-0.15.11 lib/code/node/number.rb
code-ruby-0.15.10 lib/code/node/number.rb
code-ruby-0.15.9 lib/code/node/number.rb
code-ruby-0.15.8 lib/code/node/number.rb
code-ruby-0.15.7 lib/code/node/number.rb
code-ruby-0.15.6 lib/code/node/number.rb
code-ruby-0.15.5 lib/code/node/number.rb
code-ruby-0.15.4 lib/code/node/number.rb
code-ruby-0.15.3 lib/code/node/number.rb
code-ruby-0.15.2 lib/code/node/number.rb
code-ruby-0.15.0 lib/code/node/number.rb