Class: Lisp::Boolean
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?, #object?, #pair?, #port?, #positive?, #primitive?, #print_string, #quoted, #set!, #set_location, #special?, #string?, #symbol?, #vector?, #zero?
Constructor Details
#initialize(b) ⇒ Boolean
Returns a new instance of Boolean.
16
17
18
|
# File 'lib/rubylisp/boolean.rb', line 16
def initialize(b)
@value = b
end
|
Class Method Details
8
9
10
|
# File 'lib/rubylisp/boolean.rb', line 8
def self.FALSE
@false_constant ||= Lisp::Boolean.new(false)
end
|
4
5
6
|
# File 'lib/rubylisp/boolean.rb', line 4
def self.TRUE
@true_constant ||= Lisp::Boolean.new(true)
end
|
.with_value(b) ⇒ Object
12
13
14
|
# File 'lib/rubylisp/boolean.rb', line 12
def self.with_value(b)
b ? self.TRUE : self.FALSE
end
|
Instance Method Details
24
25
26
|
# File 'lib/rubylisp/boolean.rb', line 24
def boolean?
true
end
|
40
41
42
|
# File 'lib/rubylisp/boolean.rb', line 40
def false?
!@value
end
|
28
29
30
31
32
33
34
|
# File 'lib/rubylisp/boolean.rb', line 28
def to_s
if @value
"#t"
else
"#f"
end
end
|
36
37
38
|
# File 'lib/rubylisp/boolean.rb', line 36
def true?
@value
end
|
20
21
22
|
# File 'lib/rubylisp/boolean.rb', line 20
def type
:boolean
end
|