Class: Lisp::Character
- Inherits:
-
Atom
show all
- Defined in:
- lib/rubylisp/character.rb
Constant Summary
collapse
- @@character_constants =
{}
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, #class?, #copy, #doc, #environment?, #eof_object?, #eq?, #equal?, #evaluate, #false?, #frame?, #function?, #length, #lisp_object?, #list?, #macro?, #negative?, #number?, #object?, #pair?, #port?, #positive?, #primitive?, #quoted, #set_location, #special?, #string?, #symbol?, #true?, #vector?, #zero?
Constructor Details
Returns a new instance of Character.
6
7
8
|
# File 'lib/rubylisp/character.rb', line 6
def initialize(n)
@value = n
end
|
Class Method Details
.character_constants ⇒ Object
100
101
102
|
# File 'lib/rubylisp/character.rb', line 100
def self.character_constants()
@@character_constants
end
|
Instance Method Details
16
17
18
|
# File 'lib/rubylisp/character.rb', line 16
def character?
true
end
|
#eqv?(other) ⇒ Boolean
21
22
23
24
|
# File 'lib/rubylisp/character.rb', line 21
def eqv?(other)
return false unless other.character?
@value == other.value
end
|
#find_charactername ⇒ Object
42
43
44
45
|
# File 'lib/rubylisp/character.rb', line 42
def find_charactername
@@character_constants.each {|k, v| return k if v == self}
"UNKNOWN"
end
|
#print_string ⇒ Object
48
49
50
|
# File 'lib/rubylisp/character.rb', line 48
def print_string
return "#\\#{find_charactername}"
end
|
11
12
13
|
# File 'lib/rubylisp/character.rb', line 11
def set!(n)
@value = n
end
|
32
33
34
|
# File 'lib/rubylisp/character.rb', line 32
def to_s
@value
end
|
37
38
39
|
# File 'lib/rubylisp/character.rb', line 37
def to_sym
@value.to_sym
end
|
27
28
29
|
# File 'lib/rubylisp/character.rb', line 27
def type
:character
end
|