Class: Lisp::String

Inherits:
Atom show all
Defined in:
lib/rubylisp/string.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?, #eqv?, #evaluate, #false?, #frame?, #function?, #length, #lisp_object?, #list?, #macro?, #negative?, #number?, #object?, #pair?, #port?, #positive?, #primitive?, #quoted, #set_location, #special?, #symbol?, #true?, #vector?, #zero?

Constructor Details

#initialize(n = '') ⇒ String

Returns a new instance of String.



9
10
11
# File 'lib/rubylisp/string.rb', line 9

def initialize(n = '')
  @value = n.to_s
end

Class Method Details

.with_value(n) ⇒ Object



5
6
7
# File 'lib/rubylisp/string.rb', line 5

def self.with_value(n)
  self.new(n)
end

Instance Method Details

#equal?(other) ⇒ Boolean

Returns:



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

def equal?(other)
  other.string? && self.value == other.value
end


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

def print_string
  "\"#{@value}\""
end

#set!(n) ⇒ Object



13
14
15
# File 'lib/rubylisp/string.rb', line 13

def set!(n)
  @value = n.to_s
end

#string?Boolean

Returns:



17
18
19
# File 'lib/rubylisp/string.rb', line 17

def string?
  true
end

#to_sObject



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

def to_s
  @value
end

#to_symObject



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

def to_sym
  @value.to_sym
end

#typeObject



25
26
27
# File 'lib/rubylisp/string.rb', line 25

def type
  :string
end