Class: Config
- Inherits:
- 
      Object
      
        - Object
- Config
 
- Defined in:
- lib/jott/config.rb
Instance Attribute Summary collapse
- 
  
    
      #editor  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute editor. 
Instance Method Summary collapse
- #get_editor ⇒ Object
- 
  
    
      #initialize  ⇒ Config 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Config. 
- #set_editor(editor) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
| 6 7 8 9 10 | # File 'lib/jott/config.rb', line 6 def initialize @file_path = File.join(File.dirname(__FILE__).to_s, 'jott.config') File.new(@file_path, 'w') unless File.exist?(@file_path) @editor = get_editor end | 
Instance Attribute Details
#editor ⇒ Object (readonly)
Returns the value of attribute editor.
| 4 5 6 | # File 'lib/jott/config.rb', line 4 def editor @editor end | 
Instance Method Details
#get_editor ⇒ Object
| 12 13 14 15 16 17 18 19 | # File 'lib/jott/config.rb', line 12 def get_editor File.open(@file_path, 'r') do |file| file.each_line do |line| return line.split(':')[1].strip if line.include?('editor') end end 'vi' end | 
#set_editor(editor) ⇒ Object
| 21 22 23 24 25 26 | # File 'lib/jott/config.rb', line 21 def set_editor(editor) File.open(@file_path, 'w') do |file| file.puts "editor: #{editor}" end @editor = editor end |