Class: Evertils::Controller::Log

Inherits:
Base
  • Object
show all
Defined in:
lib/evertils/controllers/log.rb

Constant Summary collapse

WORDS_PER_LINE =
20

Constants inherited from Base

Base::OK, Base::QUIT, Base::QUIT_SOFT

Instance Attribute Summary

Attributes inherited from Base

#config, #request

Instance Method Summary collapse

Methods inherited from Base

#can_exec?, #exec, #initialize, #post_exec, #sample

Constructor Details

This class inherits a constructor from Evertils::Controller::Base

Instance Method Details

#grep(text = nil) ⇒ Object

Since:

  • 2.2.0



34
35
36
37
38
39
40
# File 'lib/evertils/controllers/log.rb', line 34

def grep(text = nil)
  params = OpenStruct.new(term: text, action: 'search', notebook: 'Daily')

  runner = ActionRunner.new
  runner.params = params
  runner.execute
end

#groupObject

Since:

  • 2.2.0



44
45
46
47
48
49
50
# File 'lib/evertils/controllers/log.rb', line 44

def group
  params = OpenStruct.new(action: 'group', notebook: 'Daily')

  runner = ActionRunner.new
  runner.params = params
  runner.execute
end

#message(text = nil) ⇒ Object

Send arbitrary text to the daily log



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/evertils/controllers/log.rb', line 19

def message(text = nil)
  return Notify.error('A message is required') if text.nil?

  @note = @note_helper.find_note_by_grammar(grammar.to_s)
  text_groups = text.split(' ').each_slice(WORDS_PER_LINE).map do |w|
    w.join(' ')
  end

  return Notify.error('Note not found') if @note.entity.nil?

  modify_with(text_groups)
end

#pre_execObject



10
11
12
13
14
15
16
# File 'lib/evertils/controllers/log.rb', line 10

def pre_exec
  super

  @note = nil
  @note_helper = Evertils::Helper::Note.instance
  @api_helper = Evertils::Helper::ApiEnmlHandler.new(@config)
end