Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/lunar_cheese/dump.rb

Instance Method Summary collapse

Instance Method Details

#to_luaString

Dump the string to a format used by Don’t Starve table dumps. This will a) surround the string with quotation marks (“) and b) escape any quotation marks which it contains.

Examples:

Dumping string

puts 'Hello "John", if this truly is your name.'.to_lua
=> "Hello \"John\", if this truly is your name."

Returns:

  • (String)

    Dumped version of the string.



13
14
15
# File 'lib/lunar_cheese/dump.rb', line 13

def to_lua
  "\"#{ gsub(/"/, '\"') }\""
end