Method: Doing::WWID#last

Defined in:
lib/doing/wwid/display.rb

#last(times: true, section: nil, options: {}) ⇒ Object

Show the last entry

Parameters:

  • times (Bool) (defaults to: true)

    Show times

  • section (String) (defaults to: nil)

    Section to pull from, default Currently



250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/doing/wwid/display.rb', line 250

def last(times: true, section: nil, options: {})
  section = section.nil? || section =~ /all/i ? 'All' : guess_section(section)
  cfg = Doing.setting(['templates', options[:config_template]]).deep_merge(Doing.setting('templates.default'), { extend_existing_arrays: true, sort_merged_arrays: true }).deep_merge({
    'wrap_width' => Doing.setting('wrap_width', 0),
    'date_format' => Doing.setting('default_date_format'),
    'order' => Doing.setting('order', :asc),
    'tags_color' => Doing.setting('tags_color'),
    'duration' => Doing.setting('duration'),
    'interval_format' => Doing.setting('interval_format')
  }, { extend_existing_arrays: true, sort_merged_arrays: true })
  options[:duration] ||= cfg['duration'] || false
  options[:interval_format] ||= cfg['interval_format'] || 'text'

  opts = {
    case: options[:case],
    config_template: options[:config_template] || 'last',
    count: 1,
    delete: options[:delete],
    duration: options[:duration],
    format: cfg['date_format'],
    interval_format: options[:interval_format],
    not: options[:negate],
    output: options[:output],
    section: section,
    template: options[:template] || cfg['template'],
    times: times,
    val: options[:val],
    wrap_width: cfg['wrap_width']
  }

  if options[:tag]
    opts[:tag_filter] = {
      'tags' => options[:tag],
      'bool' => options[:tag_bool]
    }
  end

  opts[:search] = options[:search] if options[:search]

  list_section(opts)
end