Class: Kuromd::OneOnOne::Note

Inherits:
BaseNote
  • Object
show all
Includes:
Postable
Defined in:
lib/kuromd/one_on_one/note.rb

Overview

Represents a note for a 1:1

Constant Summary collapse

NOTE_TYPE =
'One on one'

Instance Attribute Summary collapse

Attributes inherited from BaseNote

#config, #note_type

Instance Method Summary collapse

Methods included from Postable

#send

Methods inherited from BaseNote

assign_note_objs, categorize_by_note_objs, parse_markdown

Constructor Details

#initialize(params = {}) ⇒ Note

Returns a new instance of Note.



15
16
17
18
19
20
21
22
23
# File 'lib/kuromd/one_on_one/note.rb', line 15

def initialize(params = {})
  super(params)
  # config = Kuromd::Configurable.get_config
  # @params = config.params['notes']['one_on_one']
  @params = @config.params['notes']['one_on_one']

  @note_type = NOTE_TYPE
  Kuromd.logger.info "One on one note initialized: #{@note_data}, #{@params}"
end

Instance Attribute Details

#note_dataObject

Returns the value of attribute note_data.



12
13
14
# File 'lib/kuromd/one_on_one/note.rb', line 12

def note_data
  @note_data
end

#note_pathObject

Returns the value of attribute note_path.



12
13
14
# File 'lib/kuromd/one_on_one/note.rb', line 12

def note_path
  @note_path
end

#one_on_one_urlObject

Returns the value of attribute one_on_one_url.



12
13
14
# File 'lib/kuromd/one_on_one/note.rb', line 12

def one_on_one_url
  @one_on_one_url
end

#paramsObject

Returns the value of attribute params.



12
13
14
# File 'lib/kuromd/one_on_one/note.rb', line 12

def params
  @params
end

Instance Method Details

#processObject



40
41
42
43
44
45
46
47
48
# File 'lib/kuromd/one_on_one/note.rb', line 40

def process
  return unless valid?

  url = @params['url']
  Kuromd.logger.info "Processing One on one note: #{@note_data['title']}, #{@note_data['note_date']} to #{url}"

  # Invoke Kuromd::Note::Postable's send method
  send(url, @note_data)
end

#valid?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/kuromd/one_on_one/note.rb', line 25

def valid?
  is_valid = false

  # has to have the category
  if category?
    # needs a note_date and monica_id
    is_valid = (!@note_data['note_date'].nil? && !@note_data['note_date'].empty?) &&
               !@note_data['monica_id'].nil? &&
               !@note_data['title'].nil?
  end

  Kuromd.logger.info "One on One note object valid? #{is_valid}"
  is_valid
end