Class: Symbol

Inherits:
Object show all
Defined in:
lib/spectator/emacs.rb

Instance Method Summary collapse

Instance Method Details

#keywordObject

Returns a symbol with the same name prefixed by a colon. This is convenient when converting a symbol with the #to_lisp method.

Example:

:foo_bar.keyword.to_lisp => ':foo-bar'


40
41
42
43
44
45
46
# File 'lib/spectator/emacs.rb', line 40

def keyword
  if self[0] == ':'
    self
  else
    ":#{to_s}".to_sym
  end
end

#to_lispObject

Returns a string that represents the symbol as a lisp symbol. Underscores are converted to dashes.

Example:

:foo_bar.to_lisp => 'foo-bar'


28
29
30
# File 'lib/spectator/emacs.rb', line 28

def to_lisp
  to_s.gsub "_", "-"
end