Class: Stool::BaseObj
- Inherits:
-
Object
- Object
- Stool::BaseObj
- Defined in:
- lib/stool/Core/BaseObj.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#doCacheByYAML(path) ⇒ Object
以yaml缓存.
-
#initialize {|_self| ... } ⇒ BaseObj
constructor
A new instance of BaseObj.
Constructor Details
#initialize {|_self| ... } ⇒ BaseObj
Returns a new instance of BaseObj.
10 11 12 13 |
# File 'lib/stool/Core/BaseObj.rb', line 10 def initialize super yield self if block_given? end |
Class Method Details
.fromFile(path) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/stool/Core/BaseObj.rb', line 15 def self.fromFile(path) if File.exist?(path) content = File.open(path, 'r:utf-8', &:read) eval(content,nil,path.to_s) end end |
.fromYAML(path) ⇒ Object
加载从yaml
23 24 25 26 27 28 |
# File 'lib/stool/Core/BaseObj.rb', line 23 def self.fromYAML(path) if File.exist?(path) content = File.open(path) YAML.load(content) end end |
Instance Method Details
#doCacheByYAML(path) ⇒ Object
以yaml缓存
31 32 33 34 35 |
# File 'lib/stool/Core/BaseObj.rb', line 31 def doCacheByYAML(path) if path File.open(path, "w") { |file| YAML.dump(self, file) } end end |