Class: Okayu::UserInfo

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

Constant Summary collapse

@@app_dir =
AppDir.to_s
@@data =
Hash.new

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



32
33
34
# File 'lib/user_info.rb', line 32

def self.[] key
  @@data[key]
end

.[]=(key, value) ⇒ Object



36
37
38
# File 'lib/user_info.rb', line 36

def self.[]= key, value
  @@data[key] = value
end

.loadObject



10
11
12
13
14
15
16
# File 'lib/user_info.rb', line 10

def self.load
  if File.exist?()
    File.open(, "r") do |f|
      @@data = YAML.load(f)
    end
  end
end

.method_missing(m, *args) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/user_info.rb', line 40

def self.method_missing(m, *args)
  if /^(.*)=$/ =~ (m.to_s)
    @@data[$1.to_sym] = args[0]
  else
    @@data[m]
  end
end

.saveObject



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

def self.save
  File.open(, "w") do |f|
    f.write YAML.dump(@@data)
  end
end

.set_app_dir(app_dir) ⇒ Object



24
25
26
# File 'lib/user_info.rb', line 24

def self.set_app_dir app_dir
  @@app_dir = app_dir
end

.user_info_fileObject



28
29
30
# File 'lib/user_info.rb', line 28

def self.
  @@app_dir + '/user_info.yml'
end