Class: Construqt::Resources
- Inherits:
-
Object
- Object
- Construqt::Resources
show all
- Defined in:
- lib/construqt/resource.rb
Defined Under Namespace
Modules: Rights
Classes: Resource, SkipFile
Instance Method Summary
collapse
Constructor Details
#initialize(region) ⇒ Resources
Returns a new instance of Resources.
19
20
21
22
|
# File 'lib/construqt/resource.rb', line 19
def initialize(region)
@region = region
@files = {}
end
|
Instance Method Details
#add_file(data, right, key, *path) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/construqt/resource.rb', line 34
def add_file(data, right, key, *path)
throw "need a key" unless key
throw "need a path #{key}" if path.empty?
throw "resource exists with key #{key}" if @files[key]
resource = Resource.new
resource.path = *path
resource.right = right
resource.data = data
@files[key] = resource
resource
end
|
#add_from_file(src_fname, right, key, *path) ⇒ Object
24
25
26
|
# File 'lib/construqt/resource.rb', line 24
def add_from_file(src_fname, right, key, *path)
add_file(IO.read(src_fname), right, key, *path)
end
|
#add_skip_file(fname) ⇒ Object
28
29
30
31
32
|
# File 'lib/construqt/resource.rb', line 28
def add_skip_file(fname)
sf = SkipFile.new
sf.path = fname
sf
end
|
#find(key) ⇒ Object
46
47
48
49
50
|
# File 'lib/construqt/resource.rb', line 46
def find(key)
ret = @files[key]
throw "resource with key #{key} not found" unless ret
ret
end
|