Class: Dsu::Views::Export

Inherits:
Object
  • Object
show all
Includes:
Support::Ask, Support::ColorThemable
Defined in:
lib/dsu/views/export.rb

Instance Method Summary collapse

Methods included from Support::ColorThemable

apply_theme, #prompt_with_options

Methods included from Support::Ask

#ask_while, #yes?

Constructor Details

#initialize(presenter:, options:) ⇒ Export

Returns a new instance of Export.



13
14
15
16
17
# File 'lib/dsu/views/export.rb', line 13

def initialize(presenter:, options:)
  @presenter = presenter
  @options = options&.dup || {}
  @color_theme = Models::ColorTheme.find(theme_name: theme_name)
end

Instance Method Details

#renderObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dsu/views/export.rb', line 19

def render
  return display_nothing_to_export_message if presenter.nothing_to_export?

  response = display_export_prompt
  if presenter.respond response: response
    display_exported_message
    display_exported_to_message(file_path: presenter.export_file_path)
  else
    display_cancelled_message
  end
rescue StandardError => e
  puts apply_theme(e.message, theme_color: color_theme.error)
  puts apply_theme(e.backtrace_locations.join("\n"), theme_color: color_theme.error) if Dsu.env.local?
end