Class: Ever2boost::Note

Inherits:
Object
  • Object
show all
Defined in:
lib/ever2boost/note.rb

Constant Summary collapse

DEFAULT_BYTES_NUMBER =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title: nil, content: nil, notebook_guid: nil, output_dir: nil) ⇒ Note

Returns a new instance of Note.



7
8
9
10
11
12
13
# File 'lib/ever2boost/note.rb', line 7

def initialize(title: nil, content: nil, notebook_guid: nil, output_dir: nil)
  @title = title
  @content = MdConverter.convert(content)
  @notebook_guid = notebook_guid
  @file_name = SecureRandom.hex(DEFAULT_BYTES_NUMBER)
  @output_dir = output_dir
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



6
7
8
# File 'lib/ever2boost/note.rb', line 6

def content
  @content
end

#file_nameObject

Returns the value of attribute file_name.



6
7
8
# File 'lib/ever2boost/note.rb', line 6

def file_name
  @file_name
end

#hashObject

Returns the value of attribute hash.



6
7
8
# File 'lib/ever2boost/note.rb', line 6

def hash
  @hash
end

#notebook_guidObject

Returns the value of attribute notebook_guid.



6
7
8
# File 'lib/ever2boost/note.rb', line 6

def notebook_guid
  @notebook_guid
end

#output_dirObject

Returns the value of attribute output_dir.



6
7
8
# File 'lib/ever2boost/note.rb', line 6

def output_dir
  @output_dir
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/ever2boost/note.rb', line 6

def title
  @title
end

Instance Method Details



19
20
21
# File 'lib/ever2boost/note.rb', line 19

def build_image_link(content_str)
  content_str.gsub(/<en-media\ hash=['|"](.+?)['|"](.*?).\ type=.(.+?)\/(.+?)['|"](.*?)\/>/, "![#{'\1'}](#{self.output_dir}/images/#{'\1'}.#{'\4'})")
end

#md_contentObject



15
16
17
# File 'lib/ever2boost/note.rb', line 15

def md_content
  build_image_link(self.content)
end