Sha256: f15d9f790a7f0bf2c4eaeba2f6fe72ec723ad2489facb9f86735d9c55cfe597e

Contents?: true

Size: 507 Bytes

Versions: 29

Compression:

Stored size: 507 Bytes

Contents

# frozen_string_literal: true

class Code
  class Node
    class Boolean < Node
      TRUE_KEYWORD = "true"
      FALSE_KEYWORD = "false"

      def initialize(parsed)
        return if parsed.blank?

        @boolean = parsed.presence
      end

      def evaluate(**_args)
        if @boolean == TRUE_KEYWORD
          Object::Boolean.new(true)
        elsif @boolean == FALSE_KEYWORD
          Object::Boolean.new(false)
        else
          Object::Nothing.new
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
code-ruby-0.14.9 lib/code/node/boolean.rb
code-ruby-0.14.8 lib/code/node/boolean.rb
code-ruby-0.14.6 lib/code/node/boolean.rb
code-ruby-0.14.5 lib/code/node/boolean.rb
code-ruby-0.14.4 lib/code/node/boolean.rb
code-ruby-0.14.3 lib/code/node/boolean.rb
code-ruby-0.14.2 lib/code/node/boolean.rb
code-ruby-0.14.1 lib/code/node/boolean.rb
code-ruby-0.14.0 lib/code/node/boolean.rb