class Noty::Bookmark
Attributes
path[RW]
title[RW]
url[RW]
Public Class Methods
from_url(url)
click to toggle source
# File lib/noty/models/bookmark.rb, line 18 def self.from_url(url) file_path = File.join(STORAGE_PATH, Time.now.to_i.to_s + '.bookmark') content = begin open(url).read rescue '' end bookmark = new(file_path) bookmark.url = url bookmark.title = content.match(%r{<title>(.+)<\/title>}im).to_a[1] bookmark end
new(path)
click to toggle source
# File lib/noty/models/bookmark.rb, line 10 def initialize(path) content = File.exist?(path) ? YAML.load_file(path) : '' @path = path @url = content['url'] @title = content['title'] end
Public Instance Methods
copy()
click to toggle source
# File lib/noty/models/bookmark.rb, line 47 def copy Helpers.copy url end
delete()
click to toggle source
# File lib/noty/models/bookmark.rb, line 35 def delete File.delete path end
edit()
click to toggle source
# File lib/noty/models/bookmark.rb, line 43 def edit Helpers.edit path end
open()
click to toggle source
# File lib/noty/models/bookmark.rb, line 39 def open Helpers.open_url url end
save()
click to toggle source
# File lib/noty/models/bookmark.rb, line 31 def save File.write(path, to_yaml) end
to_s(short = false)
click to toggle source
# File lib/noty/models/bookmark.rb, line 51 def to_s(short = false) short ? title.to_s : "#{title} (#{url})" end
Private Instance Methods
to_yaml()
click to toggle source
# File lib/noty/models/bookmark.rb, line 57 def to_yaml { 'url' => url, 'title' => title }.to_yaml end