Class: Milkode::WebSetting

Inherits:
Object
  • Object
show all
Defined in:
lib/milkode/cdweb/lib/web_setting.rb

Constant Summary collapse

DEFAULT_SETTING =
{
  :home_title    => "Milkode",
  :home_icon     => "/images/MilkodeIcon135.png",

  :header_title => "Milkode",
  :header_icon  => "/images/MilkodeIcon135.png",

  :favicon      => "/images/favicon.ico",

  :display_about_milkode => true
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWebSetting

Returns a new instance of WebSetting.



35
36
37
38
39
40
41
42
43
44
# File 'lib/milkode/cdweb/lib/web_setting.rb', line 35

def initialize
  fname = File.join(Database.dbdir, "milkweb.yaml")
  if FileTest.exist? fname
    open(fname) do |f|
      @data = YAML.load(f.read)
    end
  else
    @data = DEFAULT_SETTING
  end
end

Class Method Details

.hash_method(name) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/milkode/cdweb/lib/web_setting.rb', line 25

def self.hash_method(name)
  define_method(name) do
    if @data[name]
      @data[name]
    else
      DEFAULT_SETTING[name]
    end
  end
end

Instance Method Details

#about_milkodeObject



54
55
56
57
58
59
60
# File 'lib/milkode/cdweb/lib/web_setting.rb', line 54

def about_milkode
  if (@data[:display_about_milkode])
    ', <a href="http://milkode.ongaeshi.me">milkodeについて</a>'
  else
    ''
  end
end