Class: Captain::Resource
- Inherits:
-
Object
- Object
- Captain::Resource
- Defined in:
- lib/captain/resource.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Template
Constant Summary collapse
- PATH =
Pathname.new(File.dirname(__FILE__)).join('..', '..', 'resources')
Class Method Summary collapse
Instance Method Summary collapse
- #contents ⇒ Object
- #copy_to(*paths) ⇒ Object
-
#initialize(name) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(name) ⇒ Resource
Returns a new instance of Resource.
16 17 18 |
# File 'lib/captain/resource.rb', line 16 def initialize(name) @name = name end |
Class Method Details
.file(name) ⇒ Object
8 9 10 |
# File 'lib/captain/resource.rb', line 8 def self.file(name) new(name) end |
Instance Method Details
#contents ⇒ Object
20 21 22 |
# File 'lib/captain/resource.rb', line 20 def contents PATH.join(@name).read end |
#copy_to(*paths) ⇒ Object
24 25 26 27 28 |
# File 'lib/captain/resource.rb', line 24 def copy_to(*paths) path = File.join(paths) FileUtils.mkpath(File.dirname(path)) File.open(path, 'w') { |f| f.write(contents) } end |