Class: Lisp::NativeObject
- Inherits:
-
Atom
show all
- Defined in:
- lib/rubylisp/native_object.rb
Instance Attribute Summary
Attributes inherited from Atom
#value
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Atom
#all?, #apply_to, #car, #cdr, #character?, #class?, #copy, #doc, #environment?, #eof_object?, #eq?, #equal?, #eqv?, #evaluate, #frame?, #function?, #length, #lisp_object?, #list?, #macro?, #negative?, #number?, #pair?, #port?, #positive?, #primitive?, #print_string, #quoted, #set!, #set_location, #special?, #string?, #symbol?, #vector?, #zero?
Constructor Details
Returns a new instance of NativeObject.
13
14
15
|
# File 'lib/rubylisp/native_object.rb', line 13
def initialize(o=nil)
@value = o
end
|
Class Method Details
.new_instance_of(c) ⇒ Object
5
6
7
|
# File 'lib/rubylisp/native_object.rb', line 5
def self.new_instance_of(c)
self.new(c.alloc.init)
end
|
.with_value(o) ⇒ Object
9
10
11
|
# File 'lib/rubylisp/native_object.rb', line 9
def self.with_value(o)
self.new(o)
end
|
Instance Method Details
41
42
43
|
# File 'lib/rubylisp/native_object.rb', line 41
def false?
@value == nil
end
|
#native_type ⇒ Object
29
30
31
|
# File 'lib/rubylisp/native_object.rb', line 29
def native_type
@value.class
end
|
21
22
23
|
# File 'lib/rubylisp/native_object.rb', line 21
def object?
true
end
|
33
34
35
|
# File 'lib/rubylisp/native_object.rb', line 33
def to_s
"<a #{@value.class}: #{@value}>"
end
|
37
38
39
|
# File 'lib/rubylisp/native_object.rb', line 37
def true?
@value != nil
end
|
25
26
27
|
# File 'lib/rubylisp/native_object.rb', line 25
def type
:object
end
|
#with_value(&block) ⇒ Object
17
18
19
|
# File 'lib/rubylisp/native_object.rb', line 17
def with_value(&block)
block.call(@value)
end
|