Class: Kanye::History

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db_file) ⇒ History

Returns a new instance of History.



4
5
6
# File 'lib/kanye/history.rb', line 4

def initialize(db_file)
  @db = SQLite3::Database.new(db_file)
end

Instance Attribute Details

#dbObject (readonly)

Returns the value of attribute db.



3
4
5
# File 'lib/kanye/history.rb', line 3

def db
  @db
end

Instance Method Details

#exists?(track) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/kanye/history.rb', line 12

def exists?(track)
  db.execute("select * from tracks where key=?", track.id).any?
end

#insert(track) ⇒ Object



8
9
10
# File 'lib/kanye/history.rb', line 8

def insert(track)
  db.execute("insert into tracks values (?, ?)", [nil, track.id])
end