Class: DYAutomate::DYBaseObj

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

Direct Known Subclasses

DYAutomateConfig, DYAutomateConfigDetail

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ DYBaseObj

Returns a new instance of DYBaseObj.

Yields:

  • (_self)

Yield Parameters:



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