Class: HilferConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/hilfer/hilfer_config.rb

Overview

Read and write configuration to ~/.hilfer in yaml. Currently only writes window position

Instance Method Summary collapse

Constructor Details

#initialize(file, window, count) ⇒ HilferConfig

Returns a new instance of HilferConfig.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hilfer/hilfer_config.rb', line 10

def initialize( file, window, count )
  @file, @window = file, window

  if File.file? CONFIG_FILE
    config = YAML.load_file CONFIG_FILE
    @window.set_default_size( *config[:size] )
    @window.show_all
    # move must be after show_all otherwise it
    # gets overridden
    @window.move( *config[:position] ) if count == 1
  else
    @window.set_default_size( 300,700 ).show_all
  end
end

Instance Method Details

#saveObject

save config



26
27
28
29
30
31
32
33
# File 'lib/hilfer/hilfer_config.rb', line 26

def save
  config = {
    :path => @window.title,
    :position => @window.position,
    :size => @window.size
  }
  File.open( CONFIG_FILE, 'w' ) { |file| file.print config.to_yaml }
end