Class: PostyCli::Config

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

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object


22
23
24
# File 'lib/posty_cli/config.rb', line 22

def [](key)
  @config[key]
end

.include?(key) ⇒ Boolean

Returns:

  • (Boolean)

18
19
20
# File 'lib/posty_cli/config.rb', line 18

def include?(key)
  @config.include?(key)
end

.load(source) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/posty_cli/config.rb', line 4

def load(source)
  @config = {:posty_url => nil,:display_results_in_pager => false}

  if source.is_a?(String)
    raise "Config file #{source} not found" unless File.exist?(source)
  
    config = YAML.load_file(source)
    @config.merge! config if config

  elsif source.is_a?(Hash)
    @config.merge! source
  end
end

.to_yamlObject


26
27
28
# File 'lib/posty_cli/config.rb', line 26

def to_yaml
  @config.to_yaml
end