Class: Optimacms::CssFile
- Inherits:
-
Object
- Object
- Optimacms::CssFile
- Defined in:
- app/models/optimacms/css_file.rb
Instance Attribute Summary collapse
-
#basepath ⇒ Object
Returns the value of attribute basepath.
-
#content ⇒ Object
content.
-
#is_folder ⇒ Object
Returns the value of attribute is_folder.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
- #init_from_path(f) ⇒ Object
- #save ⇒ Object
- #save_content ⇒ Object
- #to_param ⇒ Object
- #update_attributes(p) ⇒ Object
Instance Attribute Details
#basepath ⇒ Object
Returns the value of attribute basepath.
3 4 5 |
# File 'app/models/optimacms/css_file.rb', line 3 def basepath @basepath end |
#content ⇒ Object
content
78 79 80 |
# File 'app/models/optimacms/css_file.rb', line 78 def content @content end |
#is_folder ⇒ Object
Returns the value of attribute is_folder.
3 4 5 |
# File 'app/models/optimacms/css_file.rb', line 3 def is_folder @is_folder end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'app/models/optimacms/css_file.rb', line 3 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'app/models/optimacms/css_file.rb', line 3 def path @path end |
Class Method Details
.dir_base ⇒ Object
40 41 42 |
# File 'app/models/optimacms/css_file.rb', line 40 def self.dir_base "app/assets/stylesheets" end |
.get_all ⇒ Object
32 33 34 35 |
# File 'app/models/optimacms/css_file.rb', line 32 def self.get_all get_list end |
.get_list ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/optimacms/css_file.rb', line 44 def self.get_list res = [] # #Dir["#{dir_base}/**"].each do |f| #Dir.glob(File.join(dir_base, "**", "*#{File::Separator}")).each do |f| Dir.glob(File.join(dir_base, "**", "*")).each do |f| next if File.directory?(f) r = CssFile.new r.init_from_path(f) res << r end #files = files.sort_by{ |x| File.mtime(x) }.reverse res end |
Instance Method Details
#init_from_path(f) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/optimacms/css_file.rb', line 5 def init_from_path(f) if f =~ /^#{CssFile::dir_base}/ # it is full path self.basepath = f.gsub /#{CssFile::dir_base}\/?/, '' self.path = f else # it is short path self.basepath = f self.path = "#{CssFile::dir_base}/#{f}" end # if File.file?(f) self.is_folder = false elsif File.directory?(f) self.is_folder = true end end |
#save ⇒ Object
70 71 72 73 74 |
# File 'app/models/optimacms/css_file.rb', line 70 def save save_content true end |
#save_content ⇒ Object
89 90 91 92 93 |
# File 'app/models/optimacms/css_file.rb', line 89 def save_content File.open(self.path, "w+") do |f| f.write(@content) end end |
#to_param ⇒ Object
27 28 29 |
# File 'app/models/optimacms/css_file.rb', line 27 def to_param basepath end |
#update_attributes(p) ⇒ Object
66 67 68 |
# File 'app/models/optimacms/css_file.rb', line 66 def update_attributes(p) self.content = p[:content] end |