Class: LoadDir
- Inherits:
-
Object
- Object
- LoadDir
- Defined in:
- lib/load_dir.rb
Direct Known Subclasses
Constant Summary collapse
- HTML_PATH =
Dir.pwd + '/app/views'
- CSS_PATH =
Dir.pwd + '/app/assets/stylesheets'
Instance Attribute Summary collapse
-
#directories ⇒ Object
Returns the value of attribute directories.
-
#files ⇒ Object
Returns the value of attribute files.
Instance Method Summary collapse
- #css_files(dir) ⇒ Object
- #dir_iteration ⇒ Object
- #html_files(dir) ⇒ Object
-
#initialize(*args) ⇒ LoadDir
constructor
A new instance of LoadDir.
Constructor Details
#initialize(*args) ⇒ LoadDir
Returns a new instance of LoadDir.
9 10 11 12 13 |
# File 'lib/load_dir.rb', line 9 def initialize(*args) @directories = args.flatten @files = {} dir_iteration end |
Instance Attribute Details
#directories ⇒ Object
Returns the value of attribute directories.
7 8 9 |
# File 'lib/load_dir.rb', line 7 def directories @directories end |
#files ⇒ Object
Returns the value of attribute files.
7 8 9 |
# File 'lib/load_dir.rb', line 7 def files @files end |
Instance Method Details
#css_files(dir) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/load_dir.rb', line 26 def css_files dir #Dir.foreach methods arg is only the base dir Dir.foreach(CSS_PATH) do |file| @files[file] = CSS_PATH if /#{dir}/.match(file) end end |
#dir_iteration ⇒ Object
15 16 17 18 |
# File 'lib/load_dir.rb', line 15 def dir_iteration @directories.each {|dir| html_files(dir)} @directories.each {|dir| css_files(dir)} end |
#html_files(dir) ⇒ Object
20 21 22 23 24 |
# File 'lib/load_dir.rb', line 20 def html_files dir Dir.foreach(HTML_PATH + "/" + dir) do |file| @files[file] = HTML_PATH + "/" + dir + "/" + file unless /^\./.match(file) end end |