Class: Kanye::History
- Inherits:
-
Object
- Object
- Kanye::History
- Defined in:
- lib/kanye/history.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
Instance Method Summary collapse
- #exists?(track) ⇒ Boolean
-
#initialize(db_file) ⇒ History
constructor
A new instance of History.
- #insert(track) ⇒ Object
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
#db ⇒ Object (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
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 |