Class: E621ExportDownloader::ExportHelper

Inherits:
Object
  • Object
show all
Extended by:
T::Generic, T::Sig
Defined in:
lib/e621_export_downloader/export_helper.rb

Constant Summary collapse

Model =
type_member

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, parser:, client:) ⇒ ExportHelper

Returns a new instance of ExportHelper.



21
22
23
24
25
26
# File 'lib/e621_export_downloader/export_helper.rb', line 21

def initialize(type:, parser:, client:)
  @type = type
  @parser = parser
  @client = client
  @rewind_count = T.let(0, Integer)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



18
19
20
# File 'lib/e621_export_downloader/export_helper.rb', line 18

def client
  @client
end

#parserObject (readonly)

Returns the value of attribute parser.



15
16
17
# File 'lib/e621_export_downloader/export_helper.rb', line 15

def parser
  @parser
end

#typeObject (readonly)

Returns the value of attribute type.



12
13
14
# File 'lib/e621_export_downloader/export_helper.rb', line 12

def type
  @type
end

Instance Method Details

#delete(date) ⇒ Object



34
35
36
37
# File 'lib/e621_export_downloader/export_helper.rb', line 34

def delete(date)
  client.debug("deleting export for #{type.serialize}", header: %W[helper #{format_date(date)}])
  _get(date).delete
end

#download(date) ⇒ Object



40
41
42
43
# File 'lib/e621_export_downloader/export_helper.rb', line 40

def download(date)
  client.debug("downloading export for #{type.serialize}", header: %W[helper #{format_date(date)}])
  _get(date).download
end

#exists?(date) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
# File 'lib/e621_export_downloader/export_helper.rb', line 46

def exists?(date)
  client.debug("checking export existence for #{type.serialize}", header: %W[helper #{format_date(date)}])
  _get(date).exists?
end

#format_date(date) ⇒ Object



29
30
31
# File 'lib/e621_export_downloader/export_helper.rb', line 29

def format_date(date)
  date.strftime("%Y-%m-%d")
end

#get(date) ⇒ Object



52
53
54
55
# File 'lib/e621_export_downloader/export_helper.rb', line 52

def get(date)
  client.debug("creating export handle for #{type.serialize}", header: %W[helper #{format_date(date)}])
  Export.new(date: date, helper: self)
end