Class: Hyde::GeneratedFontFile
- Inherits:
-
Jekyll::StaticFile
- Object
- Jekyll::StaticFile
- Hyde::GeneratedFontFile
- Defined in:
- lib/hyde_fonts/generated_font_file.rb
Overview
Alternative class for jekyll’s static files this allows the creation of files without a source file
Instance Attribute Summary collapse
-
#dest_path ⇒ Object
readonly
Returns the value of attribute dest_path.
-
#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) ⇒ GeneratedFontFile
constructor
A new instance of GeneratedFontFile.
- #write(dest) ⇒ Object
Constructor Details
#initialize(site, dir, name) ⇒ GeneratedFontFile
Returns a new instance of GeneratedFontFile.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/hyde_fonts/generated_font_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" @dest_path = "" end |
Instance Attribute Details
#dest_path ⇒ Object (readonly)
Returns the value of attribute dest_path.
7 8 9 |
# File 'lib/hyde_fonts/generated_font_file.rb', line 7 def dest_path @dest_path end |
#file_contents ⇒ Object
Returns the value of attribute file_contents.
6 7 8 |
# File 'lib/hyde_fonts/generated_font_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_font_file.rb', line 7 def generator @generator end |
Instance Method Details
#write(dest) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hyde_fonts/generated_font_file.rb', line 20 def write(dest) return false if File.exist?(dest_path) @dest_path = destination(dest) 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 |