class Evernote2org::Resource
Attributes
binary[RW]
doc[RW]
file_ext_name[RW]
id[RW]
mime[RW]
Public Class Methods
new(doc)
click to toggle source
# File lib/evernote2org/resource.rb, line 8 def initialize(doc) @doc = doc if recognition = @doc.css('recognition').first @id = Nokogiri::XML(recognition.content).css('recoIndex').first.attr('objID') end if @mime = @doc.css('mime').first&.content @file_ext_name = '.' + @mime.split('/').last end if data = @doc.css('data').first @binary = Base64.decode64(data.content) end end
Public Instance Methods
export_to(out_dir)
click to toggle source
# File lib/evernote2org/resource.rb, line 23 def export_to(out_dir) return unless @id && @mime File.open(File.join(out_dir, file_name), 'w') do |resource_file| resource_file.write(binary) end end
file_name()
click to toggle source
# File lib/evernote2org/resource.rb, line 30 def file_name @id + @file_ext_name end
to_img_tag(path, html_doc)
click to toggle source
# File lib/evernote2org/resource.rb, line 34 def to_img_tag(path, html_doc) img = Nokogiri::XML::Node.new('img', html_doc) img[:src] = File.join(path, file_name) img end