Class: Dsu::Views::EntryGroup::Edit

Inherits:
Object
  • Object
show all
Defined in:
lib/dsu/views/entry_group/edit.rb

Overview

TODO: I18n this class.

Instance Method Summary collapse

Constructor Details

#initialize(entry_group:, options: {}) ⇒ Edit

Returns a new instance of Edit.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
# File 'lib/dsu/views/entry_group/edit.rb', line 11

def initialize(entry_group:, options: {})
  raise ArgumentError, 'entry_group is nil' if entry_group.nil?
  raise ArgumentError, 'entry_group is the wrong object type' unless entry_group.is_a?(Models::EntryGroup)
  raise ArgumentError, 'options is nil' if options.nil?
  raise ArgumentError, 'options is the wrong object type' unless options.is_a?(Hash)

  @entry_group = entry_group
  @options = options || {}
end

Instance Method Details

#renderObject



21
22
23
# File 'lib/dsu/views/entry_group/edit.rb', line 21

def render
  puts render_as_string
end

#render_as_stringObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/dsu/views/entry_group/edit.rb', line 25

def render_as_string
  # Just in case the entry group is invalid, we'll validate it before displaying it.
  entry_group.validate!

  "    \#{banner_line}\n    # Editing DSU Entries for \#{entry_group.time_formatted}\n    \#{banner_line}\n\n    \#{entry_group_view&.chomp}\n\n    \#{banner_line}\n    # INSTRUCTIONS\n    \#{banner_line}\n    #    ADD a DSU entry: type an ENTRY DESCRIPTION on a new line.\n    #   EDIT a DSU entry: change the existing ENTRY DESCRIPTION.\n    # DELETE a DSU entry: delete the ENTRY DESCRIPTION.\n    #  NOTE: deleting all of the ENTRY DESCRIPTIONs will delete the entry group file;\n    #        this is preferable if this is what you want to do :)\n    # REORDER a DSU entry: reorder the ENTRY DESCRIPTIONs in order preference.\n    #\n    # *** When you are done, save and close your editor ***\n    \#{banner_line}\n  EDIT_VIEW\nend\n"