class Clojure::Runtime

Attributes

namespaces[R]

Public Class Methods

new() click to toggle source
# File lib/clojure/runtime.rb, line 3
def initialize
  @namespaces = {}
end

Public Instance Methods

include(lib) click to toggle source
# File lib/clojure/runtime.rb, line 13
def include(lib)
  @namespaces[lib.name.downcase.gsub("::", ".").to_sym] = lib
end
load(filename) click to toggle source
# File lib/clojure/runtime.rb, line 17
def load(filename)
  ns = Clojure::Namespace.new(self)
  source = open(filename).read
  ast = Clojure::Reader.new(source).ast
  ast.each { |form| ns.evaluate form }
  ns_name = ns["*ns*"]
  @namespaces[ns_name.to_sym] = namespace(ns_name).merge(ns)
end
namespace(name) click to toggle source
# File lib/clojure/runtime.rb, line 9
def namespace(name)
  @namespaces[name.to_sym] ||= Clojure::Namespace.new(self)
end
read(ns_name, source) click to toggle source
# File lib/clojure/runtime.rb, line 26
def read(ns_name, source)
  ast = Clojure::Reader.new(source).ast
  ns = namespace ns_name.to_sym
  ast.map { |form| ns.evaluate form }.last
end