class Lisp::Character

Public Class Methods

character_constants() click to toggle source
# File lib/rubylisp/character.rb, line 99
def self.character_constants()
  @@character_constants
end
new(n) click to toggle source
# File lib/rubylisp/character.rb, line 5
def initialize(n)
  @value = n
end
with_value(n) click to toggle source
# File lib/rubylisp/character.rb, line 104
def self.with_value(n)
  if n.length == 1
    ch = Lisp::PrimCharacter.find_character_for_chr(n[0])
    return ch unless ch.nil?
    ch = self.new(n[0])
    @@character_constants[n] = ch
    ch
  elsif @@character_constants.has_key?(n)
    @@character_constants[n]
  elsif n[0..1] == "U+"
    Lisp::PrimCharacter.find_character_for_chr(n[2..-1].to_i(16).chr)
  else
    return Lisp::Debug.process_error("Invalid character name: #{n}", Lisp::EnvironmentFrame.global)
  end
end

Public Instance Methods

character?() click to toggle source
# File lib/rubylisp/character.rb, line 15
def character?
  true
end
eqv?(other) click to toggle source
# File lib/rubylisp/character.rb, line 20
def eqv?(other)
  return false unless other.character?
  @value == other.value
end
find_charactername() click to toggle source
# File lib/rubylisp/character.rb, line 41
def find_charactername
  @@character_constants.each {|k, v| return k if v == self}
  "UNKNOWN"
end
print_string() click to toggle source
set!(n) click to toggle source
# File lib/rubylisp/character.rb, line 10
def set!(n)
  @value = n
end
to_s() click to toggle source
# File lib/rubylisp/character.rb, line 31
def to_s
  @value
end
to_sym() click to toggle source
# File lib/rubylisp/character.rb, line 36
def to_sym
  @value.to_sym
end
type() click to toggle source
# File lib/rubylisp/character.rb, line 26
def type
  :character
end