class NvimConf::Generators::Globals::Code::Lua
Public Class Methods
new(global)
click to toggle source
# File lib/nvim_conf/generators/code/globals/lua.rb, line 6 def initialize(global) @global = global end
Public Instance Methods
generate()
click to toggle source
# File lib/nvim_conf/generators/code/globals/lua.rb, line 10 def generate [ "vim.g.#{@global.name}", format_value(@global.value) ].join(" = ") end
Private Instance Methods
fallback_to_truthy_on_nil(value)
click to toggle source
# File lib/nvim_conf/generators/code/globals/lua.rb, line 38 def fallback_to_truthy_on_nil(value) return value unless value.nil? @setting.operation == :set end
format_value(value)
click to toggle source
# File lib/nvim_conf/generators/code/globals/lua.rb, line 19 def format_value(value) case value when String [ '"', value, '"' ].join when Array [ "{", value.map { |inner_value| format_value(inner_value) }.join(", "), "}" ].join else fallback_to_truthy_on_nil(value) end end