Class: Zillace::Bookmark

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fk:, title:, date_added:, last_modified:, database: Database.new.connect) ⇒ Bookmark

Returns a new instance of Bookmark.



72
73
74
75
76
77
78
# File 'lib/zillace.rb', line 72

def initialize(fk:, title:, date_added:, last_modified:, database: Database.new.connect)
  @fk = fk
  @title = title
  @date_added = date_added
  @last_modified = last_modified
  @database = database
end

Instance Attribute Details

#date_addedObject (readonly)

Returns the value of attribute date_added.



70
71
72
# File 'lib/zillace.rb', line 70

def date_added
  @date_added
end

#last_modifiedObject (readonly)

Returns the value of attribute last_modified.



70
71
72
# File 'lib/zillace.rb', line 70

def last_modified
  @last_modified
end

#titleObject (readonly)

Returns the value of attribute title.



70
71
72
# File 'lib/zillace.rb', line 70

def title
  @title
end

Class Method Details

.each(database: Database.new.connect, &block) ⇒ Object



80
81
82
83
84
85
86
87
88
89
# File 'lib/zillace.rb', line 80

def self.each(database: Database.new.connect, &block)
  enumerator = Enumerator.new do |enumerator|
    database.execute('select fk, title, dateAdded, lastModified from moz_bookmarks') do |row|
      fk, title, date_added, last_modified = row
      enumerator << new(fk:, title:, date_added: ::Zillace.prtime(date_added), last_modified: ::Zillace.prtime(last_modified), database:)
    end
  end

  block_given? ? enumerator.each(&block) : enumerator
end

Instance Method Details

#urlObject



91
92
93
# File 'lib/zillace.rb', line 91

def url
  Place.find(@fk, database: @database).url
end