Class: Database
- Inherits:
-
Object
- Object
- Database
- Defined in:
- lib/clear/database.rb
Constant Summary collapse
- FILENAME =
"LocalTasks.sqlite"
- PACKAGE =
"com.realmacsoftware.clear.mac"
- PATH =
"/Library/Containers/#{PACKAGE}/Data/Library/Application " + "Support/#{PACKAGE}/#{FILENAME}"
Instance Method Summary collapse
- #completed(&block) ⇒ Object
- #connection ⇒ Object
-
#initialize ⇒ Database
constructor
A new instance of Database.
- #lists(&block) ⇒ Object
- #tasks(list, &block) ⇒ Object
Constructor Details
#initialize ⇒ Database
Returns a new instance of Database.
9 10 11 |
# File 'lib/clear/database.rb', line 9 def initialize connect end |
Instance Method Details
#completed(&block) ⇒ Object
18 19 20 21 22 |
# File 'lib/clear/database.rb', line 18 def completed(&block) connection.execute( "select * from completed_tasks" ) do |row| block.call(row) unless block.nil? end end |
#connection ⇒ Object
13 14 15 16 |
# File 'lib/clear/database.rb', line 13 def connection connect if @@connection.nil? @@connection end |
#lists(&block) ⇒ Object
24 25 26 27 28 |
# File 'lib/clear/database.rb', line 24 def lists(&block) connection.execute( "select * from lists" ) do |row| block.call(row) unless block.nil? end end |
#tasks(list, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/clear/database.rb', line 30 def tasks(list, &block) query = "select * from tasks" unless list.nil? query = "select * from tasks where list_identifier = \"#{list.identifier}\"" end connection.execute(query) do |row| block.call(row) unless block.nil? end end |