Module: FatCore::Symbol

Included in:
Symbol
Defined in:
lib/fat_core/symbol.rb

Instance Method Summary collapse

Instance Method Details

#as_stringString Also known as: entitle

Convert to a title-ized string, that is, convert all '_' to a space, then call String#entitle on the result.

Examples:

:hello_world.entitle #=> "Hello World"
:hello_world.as_string #=> "Hello World"
:joy_to_the_world #=> 'Joy to the World'

Returns:



14
15
16
# File 'lib/fat_core/symbol.rb', line 14

def as_string
  to_s.tr('_', ' ').split(' ').join(' ').entitle
end

#as_symSymbol

Return self. This (together with String#as_sym) allows #as_sym to be applied to a string or Symbol and get back a Symbol with out testing for type.

Returns:



24
25
26
# File 'lib/fat_core/symbol.rb', line 24

def as_sym
  self
end

#tex_quoteString

Prepare this symbol for use in a TeX document by converting to String then quoting it.

Examples:

:hammer_smith.tex_quote  #=> "hammer\\_smith"

Returns:



35
36
37
# File 'lib/fat_core/symbol.rb', line 35

def tex_quote
  to_s.tex_quote
end