Class: GptTranslate::Generator::DownloadedFile

Inherits:
Jekyll::StaticFile
  • Object
show all
Defined in:
lib/jekyll-chatgpt-translate/generator.rb

Overview

The file we just downloaded.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site, link, html) ⇒ DownloadedFile

Returns a new instance of DownloadedFile.



160
161
162
163
164
# File 'lib/jekyll-chatgpt-translate/generator.rb', line 160

def initialize(site, link, html)
  super(site, site.dest, '', link)
  @html = html
  @link = link
end

Instance Attribute Details

Returns the value of attribute link.



158
159
160
# File 'lib/jekyll-chatgpt-translate/generator.rb', line 158

def link
  @link
end

Instance Method Details

#write(_dest) ⇒ Object



166
167
168
169
170
171
# File 'lib/jekyll-chatgpt-translate/generator.rb', line 166

def write(_dest)
  FileUtils.mkdir_p(File.dirname(path))
  File.write(path, @html)
  Jekyll.logger.info("Saved #{@html.split.count} words to #{path.inspect}")
  true
end