Sha256: a2afb154ae302e41612d99aaf54f89ac6fc124819a950a83a21a031a83edacc6

Contents?: true

Size: 506 Bytes

Versions: 4

Compression:

Stored size: 506 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

4 entries across 4 versions & 1 rubygems

Version Path
code-ruby-0.13.1 lib/code/node/boolean.rb
code-ruby-0.13.0 lib/code/node/boolean.rb
code-ruby-0.12.0 lib/code/node/boolean.rb
code-ruby-0.11.0 lib/code/node/boolean.rb