Class: Evertils::Type::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/evertils/type.rb

Direct Known Subclasses

Daily, Monthly, MonthlyTaskSummary, PriorityQueue, Weekly

Constant Summary collapse

COLOUR =
0xffffff
MAX_SEARCH_SIZE =
21

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, *args) ⇒ Base

Returns a new instance of Base.

Since:

  • 0.3.7



11
12
13
14
15
16
17
18
19
# File 'lib/evertils/type.rb', line 11

def initialize(config, *args)
  # helpers
  @note_helper = Evertils::Helper.load('Note')
  @format = Evertils::Helper.load('Formatting')

  @config = config if config
  @api = Evertils::Helper.load('ApiEnmlHandler', @config)
  @args = args unless args.size.zero?
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



4
5
6
# File 'lib/evertils/type.rb', line 4

def content
  @content
end

#notebookObject (readonly)

Returns the value of attribute notebook.



4
5
6
# File 'lib/evertils/type.rb', line 4

def notebook
  @notebook
end

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'lib/evertils/type.rb', line 4

def title
  @title
end

Instance Method Details

#createObject

Since:

  • 0.3.7



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/evertils/type.rb', line 23

def create
  data = {
    title: @title,
    body: @content.to_s.delete("\n"),
    parent_notebook: self.class::NOTEBOOK,
    tags: tags || [],
    colour: self.class::COLOUR
  }

  raise 'Invalid title' if @title.nil?
  raise 'Invalid note content' if @content.nil?
  raise 'Invalid notebook' if self.class::NOTEBOOK.nil?

  @note_helper.create_note(data)
end

#morning_note?Boolean

Returns:

  • (Boolean)

Since:

  • 0.3.15



53
54
55
# File 'lib/evertils/type.rb', line 53

def morning_note?
  !caller.grep(/morning/).nil?
end

#should_create?Boolean

Returns:

  • (Boolean)

Since:

  • 0.3.7



41
42
43
44
45
46
47
48
49
# File 'lib/evertils/type.rb', line 41

def should_create?
  @note = @note_helper.find_note(self.class::NOTEBOOK)
  @entity = @note.entity
  result = @entity.nil?

  Notify.warning "#{self.class.name} skipped, note already exists" unless result

  result
end