Class: Clojure::Runtime

Inherits:
Object
  • Object
show all
Defined in:
lib/clojure/runtime.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRuntime

Returns a new instance of Runtime.



5
6
7
# File 'lib/clojure/runtime.rb', line 5

def initialize
  @namespaces = {}
end

Instance Attribute Details

#namespacesObject (readonly)

Returns the value of attribute namespaces.



9
10
11
# File 'lib/clojure/runtime.rb', line 9

def namespaces
  @namespaces
end

Instance Method Details

#include(lib) ⇒ Object



15
16
17
# File 'lib/clojure/runtime.rb', line 15

def include(lib)
  @namespaces[lib.name.downcase.gsub("::", ".").to_sym] = lib
end

#namespace(name) ⇒ Object



11
12
13
# File 'lib/clojure/runtime.rb', line 11

def namespace(name)
  @namespaces[name.to_sym] ||= Clojure::Namespace.new(self)
end

#read(ns_name, source) ⇒ Object



19
20
21
22
23
# File 'lib/clojure/runtime.rb', line 19

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