Sha256: 452c994f189e14f9ca594dc0af411e6a4f2b465e9881f3ef20ad6bda661b32dd

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

class Code
  class Node
    class Statement
      def initialize(statement)
        if statement.key?(:nothing)
          @statement = ::Code::Node::Nothing.new
        elsif statement.key?(:boolean)
          @statement = ::Code::Node::Boolean.new(statement[:boolean])
        elsif statement.key?(:number)
          @statement = ::Code::Node::Number.new(statement[:number])
        elsif statement.key?(:string)
          @statement = ::Code::Node::String.new(statement[:string])
        elsif statement.key?(:call)
          @statement = ::Code::Node::Call.new(statement[:call])
        elsif statement.key?(:name)
          @statement = ::Code::Node::Name.new(statement[:name])
        elsif statement.key?(:list)
          @statement = ::Code::Node::List.new(statement[:list])
        elsif statement.key?(:dictionnary)
          @statement = ::Code::Node::Dictionnary.new(statement[:dictionnary])
        else
          raise NotImplementedError.new(statement.inspect)
        end
      end

      def evaluate(context)
        @statement.evaluate(context)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
template-ruby-0.1.0 lib/code/node/statement.rb