Class: DYAutomate::DYBaseObj
- Inherits:
-
Object
- Object
- DYAutomate::DYBaseObj
- Defined in:
- lib/Core/DYBaseObj.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#doCacheByYAML(path) ⇒ Object
以yaml缓存.
-
#initialize {|_self| ... } ⇒ DYBaseObj
constructor
A new instance of DYBaseObj.
Constructor Details
#initialize {|_self| ... } ⇒ DYBaseObj
Returns a new instance of DYBaseObj.
8 9 10 11 |
# File 'lib/Core/DYBaseObj.rb', line 8 def initialize super yield self if block_given? end |
Class Method Details
.fromFile(path) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/Core/DYBaseObj.rb', line 13 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
21 22 23 24 25 26 |
# File 'lib/Core/DYBaseObj.rb', line 21 def self.fromYAML(path) if File.exist?(path) content = File.open(path) YAML.load(content) end end |
Instance Method Details
#doCacheByYAML(path) ⇒ Object
以yaml缓存
29 30 31 32 33 |
# File 'lib/Core/DYBaseObj.rb', line 29 def doCacheByYAML(path) if path File.open(path, "w") { |file| YAML.dump(self, file) } end end |