Class: Evertils::Type::Base
- Inherits:
-
Object
- Object
- Evertils::Type::Base
- Defined in:
- lib/evertils/type.rb
Direct Known Subclasses
Constant Summary collapse
- COLOUR =
0xffffff
- MAX_SEARCH_SIZE =
21
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#notebook ⇒ Object
readonly
Returns the value of attribute notebook.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(config, *args) ⇒ Base
constructor
A new instance of Base.
- #morning_note? ⇒ Boolean
- #should_create? ⇒ Boolean
Constructor Details
#initialize(config, *args) ⇒ Base
Returns a new instance of Base.
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
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/evertils/type.rb', line 4 def content @content end |
#notebook ⇒ Object (readonly)
Returns the value of attribute notebook.
4 5 6 |
# File 'lib/evertils/type.rb', line 4 def notebook @notebook end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/evertils/type.rb', line 4 def title @title end |
Instance Method Details
#create ⇒ Object
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: || [], 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
53 54 55 |
# File 'lib/evertils/type.rb', line 53 def morning_note? !caller.grep(/morning/).nil? end |
#should_create? ⇒ Boolean
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 |