Class: Swivel2::Config

Inherits:
Struct
  • Object
show all
Defined in:
lib/swivel2/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



7
8
9
# File 'lib/swivel2/config.rb', line 7

def initialize options = {}
  options.each do |k, v| self[k] = v end
end

Instance Attribute Details

#extra_paramsObject

Returns the value of attribute extra_params

Returns:

  • (Object)

    the current value of extra_params



6
7
8
# File 'lib/swivel2/config.rb', line 6

def extra_params
  @extra_params
end

#siteObject

Returns the value of attribute site

Returns:

  • (Object)

    the current value of site



6
7
8
# File 'lib/swivel2/config.rb', line 6

def site
  @site
end

#timeout_readObject

Returns the value of attribute timeout_read

Returns:

  • (Object)

    the current value of timeout_read



6
7
8
# File 'lib/swivel2/config.rb', line 6

def timeout_read
  @timeout_read
end

#timeout_writeObject

Returns the value of attribute timeout_write

Returns:

  • (Object)

    the current value of timeout_write



6
7
8
# File 'lib/swivel2/config.rb', line 6

def timeout_write
  @timeout_write
end

Class Method Details

.defaultObject



25
26
27
# File 'lib/swivel2/config.rb', line 25

def self.default
  @@default ||= self.load default_config_file
end

.load(file = nil) ⇒ Object



21
22
23
# File 'lib/swivel2/config.rb', line 21

def self.load file = nil
  YAML.load_file(file || config_file)
end

Instance Method Details

#save(file = nil) ⇒ Object



15
16
17
18
19
# File 'lib/swivel2/config.rb', line 15

def save file = nil
  File.open file || Config.config_file, 'w' do |f|
    YAML.dump self, f
  end
end