Class: Symbol

Inherits:
Object
  • Object
show all
Defined in:
lib/rubylisp/types.rb

Overview

Monkey-patch Ruby symbols to act more like Clojure keywords

Instance Method Summary collapse

Instance Method Details

#call(target) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/rubylisp/types.rb', line 22

def call(target)
  if [Hash, Hamster::Hash].member? target.class
    target[self]
  else
    target.instance_variable_get "@#{name}".to_sym
  end
end

#nameObject



13
14
15
16
17
18
19
20
# File 'lib/rubylisp/types.rb', line 13

def name
	without_colon = inspect[1..-1]
   if without_colon[0] == '"' && without_colon[-1] == '"'
     without_colon[1..-2]
   else
     without_colon
   end
end