Class: Hyde::GeneratedCssFile
- Inherits:
-
Jekyll::StaticFile
- Object
- Jekyll::StaticFile
- Hyde::GeneratedCssFile
- Defined in:
- lib/hyde_fonts/generated_css_file.rb
Overview
Alternative class for jekyll’s static files this allows the creation of files without a source file
Instance Attribute Summary collapse
-
#file_contents ⇒ Object
Returns the value of attribute file_contents.
-
#generator ⇒ Object
readonly
Returns the value of attribute generator.
Instance Method Summary collapse
-
#initialize(site, dir, name) ⇒ GeneratedCssFile
constructor
A new instance of GeneratedCssFile.
- #write(dest) ⇒ Object
Constructor Details
#initialize(site, dir, name) ⇒ GeneratedCssFile
Returns a new instance of GeneratedCssFile.
9 10 11 12 13 14 15 16 17 |
# File 'lib/hyde_fonts/generated_css_file.rb', line 9 def initialize(site, dir, name) @site = site @dir = dir @name = name @relative_path = File.join(*[@dir, @name].compact) @extname = File.extname(@name) @type = @collection&.label&.to_sym @generator = "hyde_fonts" end |
Instance Attribute Details
#file_contents ⇒ Object
Returns the value of attribute file_contents.
6 7 8 |
# File 'lib/hyde_fonts/generated_css_file.rb', line 6 def file_contents @file_contents end |
#generator ⇒ Object (readonly)
Returns the value of attribute generator.
7 8 9 |
# File 'lib/hyde_fonts/generated_css_file.rb', line 7 def generator @generator end |
Instance Method Details
#write(dest) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hyde_fonts/generated_css_file.rb', line 19 def write(dest) dest_path = destination(dest) return false if File.exist?(dest_path) FileUtils.mkdir_p(File.dirname(dest_path)) FileUtils.rm(dest_path) if File.exist?(dest_path) File.open(dest_path, "w") do |output_file| output_file << file_contents end true end |