Class: Take::Project::File
- Inherits:
-
Object
- Object
- Take::Project::File
- Extended by:
- Forwardable
- Defined in:
- lib/take/project/file.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name) ⇒ File
constructor
A new instance of File.
- #sub_ext(ext) ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(name) ⇒ File
Returns a new instance of File.
20 21 22 |
# File 'lib/take/project/file.rb', line 20 def initialize(name) @name = name end |
Class Method Details
.normalize(file, path) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/take/project/file.rb', line 9 def self.normalize(file, path) = ::File.(file, path) raise ArgumentError, "The given file cannot be placed in " \ "the project: #{file.inspect}" \ unless .start_with?(path.to_s) name = Pathname.new() name.relative_path_from(path) end |
Instance Method Details
#sub_ext(ext) ⇒ Object
42 43 44 |
# File 'lib/take/project/file.rb', line 42 def sub_ext(ext) File.new(@name.sub_ext(ext)) end |
#type ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/take/project/file.rb', line 24 def type @_type ||= begin case @name.extname when ".ta" :library when ".to", ".o" :object when ".c" :source when "" :executable else :unknown end end end |