class RubyEdit::Configuration
Public Class Methods
new()
click to toggle source
# File lib/ruby_edit/configuration.rb, line 7 def initialize @config = TTY::Config.new @config.read("#{RubyEdit::CONFIGURATION_LOCATION}.yml") end
Public Instance Methods
editor()
click to toggle source
# File lib/ruby_edit/configuration.rb, line 12 def editor @config.fetch(:editor) || 'vim' end
editor=(editor)
click to toggle source
# File lib/ruby_edit/configuration.rb, line 16 def editor=(editor) @config.set(:editor, value: editor) write end
grep_options()
click to toggle source
# File lib/ruby_edit/configuration.rb, line 21 def grep_options options = @config.fetch(:grep_options) || 'ir' # The n option is needed for edited changes to be applied, so it needs to be added here # automatically "#{options}n" end
grep_options=(grep_options)
click to toggle source
# File lib/ruby_edit/configuration.rb, line 28 def grep_options=(grep_options) # All occurences of n are removed, as n is autamatically added when the options are fetched. @config.set(:grep_options, value: grep_options.gsub('n', '')) write end
reset_defaults()
click to toggle source
# File lib/ruby_edit/configuration.rb, line 34 def reset_defaults @config.set(:editor, value: 'vim') @config.set(:grep_options, value: 'ir') write end
Private Instance Methods
write()
click to toggle source
# File lib/ruby_edit/configuration.rb, line 42 def write @config.write("#{RubyEdit::CONFIGURATION_LOCATION}.yml", force: true) end