Class: Snapdragon::FileBase
- Inherits:
-
Object
- Object
- Snapdragon::FileBase
- Defined in:
- lib/snapdragon/file_base.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(path) ⇒ FileBase
constructor
A new instance of FileBase.
- #relative_url_path ⇒ Object
- #require_files ⇒ Object
- #require_paths ⇒ Object
Constructor Details
#initialize(path) ⇒ FileBase
Returns a new instance of FileBase.
5 6 7 |
# File 'lib/snapdragon/file_base.rb', line 5 def initialize(path) @path = path end |
Instance Method Details
#relative_url_path ⇒ Object
9 10 11 |
# File 'lib/snapdragon/file_base.rb', line 9 def relative_url_path ::File.join('/', @path.path) end |
#require_files ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/snapdragon/file_base.rb', line 29 def require_files files = [] require_paths.each do |require_path| files << Snapdragon::RequireFile.new(Snapdragon::Path.new(require_path)) end return files end |
#require_paths ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/snapdragon/file_base.rb', line 13 def require_paths f = ::File.open(::File.(@path.path), 'r') lines = f.readlines f.close require_paths = [] lines.each do |line| if line =~ /\/\/+\s+require_relative\(['"](.+)['"]\).*$/ require_paths << ::File.join(::File.dirname(@path.path), $1) end end return require_paths end |