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

#initialize(o = nil) ⇒ NativeObject

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

#false?Boolean

Returns:



41
42
43
# File 'lib/rubylisp/native_object.rb', line 41

def false?
  @value == nil
end

#native_typeObject



29
30
31
# File 'lib/rubylisp/native_object.rb', line 29

def native_type
  @value.class
end

#object?Boolean

Returns:



21
22
23
# File 'lib/rubylisp/native_object.rb', line 21

def object?
  true
end

#to_sObject



33
34
35
# File 'lib/rubylisp/native_object.rb', line 33

def to_s
  "<a #{@value.class}: #{@value}>"
end

#true?Boolean

Returns:



37
38
39
# File 'lib/rubylisp/native_object.rb', line 37

def true?
  @value != nil
end

#typeObject



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