Class: Twitorious::Config

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

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



3
4
5
6
# File 'lib/twitorious/config.rb', line 3

def initialize
  @file   = File.expand_path(File.join(['~', '.twitorious']))
  @config = YAML.load_file(@file)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



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

def method_missing(sym, *args)
  return @config[sym] if @config.has_key?(sym)
  super(sym, args)
end

Instance Method Details

#[](key) ⇒ Object



8
9
10
11
# File 'lib/twitorious/config.rb', line 8

def [](key)
  return @config[key] if @config.has_key?(key)
  return nil
end

#[]=(key, value) ⇒ Object



13
14
15
16
# File 'lib/twitorious/config.rb', line 13

def []=(key, value)
  @config[key] = value
  return @config[key]
end

#saveObject



18
19
20
21
22
# File 'lib/twitorious/config.rb', line 18

def save
  File.open(@file, "w") do |f|
    f.puts @config.to_yaml
  end
end