Class: Construqt::Resources
- Inherits:
-
Object
- Object
- Construqt::Resources
show all
- Defined in:
- lib/construqt/resource.rb
Defined Under Namespace
Modules: Component, Rights
Classes: Resource, SkipFile
Instance Method Summary
collapse
Constructor Details
#initialize(region) ⇒ Resources
Returns a new instance of Resources.
41
42
43
44
|
# File 'lib/construqt/resource.rb', line 41
def initialize(region)
@region = region
@files = {}
end
|
Instance Method Details
#add_file(data, right, key, *path) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/construqt/resource.rb', line 56
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
46
47
48
|
# File 'lib/construqt/resource.rb', line 46
def add_from_file(src_fname, right, key, *path)
add_file(IO.read(src_fname), right, key, *path)
end
|
#add_skip_file(fname) ⇒ Object
50
51
52
53
54
|
# File 'lib/construqt/resource.rb', line 50
def add_skip_file(fname)
sf = SkipFile.new
sf.path = fname
sf
end
|
#find(key) ⇒ Object
68
69
70
71
72
|
# File 'lib/construqt/resource.rb', line 68
def find(key)
ret = @files[key]
throw "resource with key #{key} not found" unless ret
ret
end
|