Class: Stool::BaseObj

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

Direct Known Subclasses

Config, LibInfo, PoolInfo, RepoInfo, TaskInfo

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of BaseObj.

Yields:

  • (_self)

Yield Parameters:



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