Class: RubyEdit::Configuration
- Inherits:
-
Object
- Object
- RubyEdit::Configuration
- Defined in:
- lib/ruby_edit/configuration.rb
Instance Method Summary collapse
- #editor ⇒ Object
- #editor=(editor) ⇒ Object
- #grep_options ⇒ Object
- #grep_options=(grep_options) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #reset_defaults ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 |
# File 'lib/ruby_edit/configuration.rb', line 7 def initialize @config = TTY::Config.new @config.read("#{RubyEdit::CONFIGURATION_LOCATION}.yml") end |
Instance Method Details
#editor ⇒ Object
12 13 14 |
# File 'lib/ruby_edit/configuration.rb', line 12 def editor @config.fetch(:editor) || 'vim' end |
#editor=(editor) ⇒ Object
16 17 18 19 |
# File 'lib/ruby_edit/configuration.rb', line 16 def editor=(editor) @config.set(:editor, value: editor) write end |
#grep_options ⇒ Object
21 22 23 24 25 26 |
# File 'lib/ruby_edit/configuration.rb', line 21 def = @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) ⇒ Object
28 29 30 31 32 |
# File 'lib/ruby_edit/configuration.rb', line 28 def () # All occurences of n are removed, as n is autamatically added when the options are fetched. @config.set(:grep_options, value: .gsub('n', '')) write end |
#reset_defaults ⇒ Object
34 35 36 37 38 |
# File 'lib/ruby_edit/configuration.rb', line 34 def reset_defaults @config.set(:editor, value: 'vim') @config.set(:grep_options, value: 'ir') write end |