~tim/scheme-vm

ref: c5110102ce2df2d78a0c87f293edf20f5a3984e7 scheme-vm/vm/char.rb -rw-r--r-- 366 bytes
c5110102Tim Morgan Add more char functions 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class VM
  class Char
    def initialize(code)
      @code = code
    end

    def self.from_string(str)
      new(str.ord)
    end

    def raw
      @code
    end

    def ==(other)
      return false unless other.is_a?(Char)
      raw == other.raw
    end

    alias eq? ==

    def to_s
      @code.chr
    end

    def to_ruby
      @code.chr
    end
  end
end