Class: Noteman::Note

Inherits:
Object
  • Object
show all
Includes:
Config, MDProcessor
Defined in:
lib/noteman/note.rb

Constant Summary

Constants included from Config

Config::CONFIG_NAME

Instance Attribute Summary collapse

Attributes included from Config

#config

Instance Method Summary collapse

Methods included from MDProcessor

#get_md, #get_metadata, #remove_metadata

Methods included from Config

#home_config, #read_from_file

Constructor Details

#initialize(file) ⇒ Note

Returns a new instance of Note.



6
7
8
9
10
11
# File 'lib/noteman/note.rb', line 6

def initialize(file)
  @file = file
  @content = File.read file
   =  @content
  @body =  @content
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/noteman/note.rb', line 4

def body
  @body
end

#contentObject

Returns the value of attribute content.



4
5
6
# File 'lib/noteman/note.rb', line 4

def content
  @content
end

#fileObject

Returns the value of attribute file.



4
5
6
# File 'lib/noteman/note.rb', line 4

def file
  @file
end

#metadataObject

Returns the value of attribute metadata.



4
5
6
# File 'lib/noteman/note.rb', line 4

def 
  
end

#tagsObject

Returns the value of attribute tags.



4
5
6
# File 'lib/noteman/note.rb', line 4

def tags
  @tags
end

Instance Method Details

#contains?(keywords) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/noteman/note.rb', line 30

def contains?(keywords)
  keywords.all? { |word| body.downcase.include? word.downcase }
end

#viewObject



34
35
36
# File 'lib/noteman/note.rb', line 34

def view
      system("open -a \"#{config['view_with']}\" #{file}")
end

#with_tags?(tags) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
# File 'lib/noteman/note.rb', line 21

def with_tags?(tags)
  if  and ['tags']
    if (tags - ['tags']).empty?
      return true
    end
  end
  false
end