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.
- #layout_files(dir) ⇒ Object
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
37 38 39 40 41 42 |
# File 'lib/load_dir.rb', line 37 def css_files dir #Dir.foreach methods arg is only the base dir Dir.foreach(CSS_PATH) do |file| self.files[file] = CSS_PATH if /(#{dir}|application)/.match(file) end end |
#dir_iteration ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/load_dir.rb', line 15 def dir_iteration @directories.each do |dir| html_files(dir) layout_files(dir) css_files(dir) end end |
#html_files(dir) ⇒ Object
23 24 25 26 27 |
# File 'lib/load_dir.rb', line 23 def html_files dir Dir.foreach(HTML_PATH + "/" + dir) do |file| self.files[file] = HTML_PATH + "/" + dir + "/" + file unless /^\./.match(file) end end |
#layout_files(dir) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/load_dir.rb', line 29 def layout_files dir Dir.foreach(HTML_PATH + "/layouts") do |file| if /(#{dir}\.html|application\.html)/.match(file) self.files[file] = HTML_PATH + "/layouts/" + file unless /^\./.match(file) end end end |