lloydpick-toast 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/toast.rb +27 -0
 - metadata +1 -1
 
    
        data/lib/toast.rb
    CHANGED
    
    | 
         @@ -179,6 +179,33 @@ module Toast 
     | 
|
| 
       179 
179 
     | 
    
         
             
                  end
         
     | 
| 
       180 
180 
     | 
    
         
             
                end
         
     | 
| 
       181 
181 
     | 
    
         | 
| 
      
 182 
     | 
    
         
            +
                def self.check
         
     | 
| 
      
 183 
     | 
    
         
            +
                  db = SQLite3::Database.new("toast.db")
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
                  db.results_as_hash = true
         
     | 
| 
      
 186 
     | 
    
         
            +
                  puts "Listing Toasters in toast.db...\n"
         
     | 
| 
      
 187 
     | 
    
         
            +
                  puts "------------------------------------------------------------"
         
     | 
| 
      
 188 
     | 
    
         
            +
                  db.execute("select * from toasters group by complete") do |toaster|
         
     | 
| 
      
 189 
     | 
    
         
            +
                    puts "\tID:\t\t" + toaster["id"]
         
     | 
| 
      
 190 
     | 
    
         
            +
                    puts "\tFrequency:\t" + toaster["frequency"]
         
     | 
| 
      
 191 
     | 
    
         
            +
                    puts "\tLast check:\t" + toaster["last_check"]
         
     | 
| 
      
 192 
     | 
    
         
            +
                    puts "\tNext check:\t" + (Time.parse(toaster["last_check"]) + toaster["frequency"].to_i).to_s
         
     | 
| 
      
 193 
     | 
    
         
            +
                    puts "\tTime now:\t" + Time.now.to_s
         
     | 
| 
      
 194 
     | 
    
         
            +
                    puts "\tOverdue?\t" + if ((Time.parse(toaster["last_check"]) + toaster["frequency"].to_i) < Time.now) then "Yes" else "No" end
         
     | 
| 
      
 195 
     | 
    
         
            +
                    puts "\tComplete?\t" + if (toaster["complete"].to_i == 1) then "Yes" else "No" end
         
     | 
| 
      
 196 
     | 
    
         
            +
                    puts "\n\tConditions...\n"
         
     | 
| 
      
 197 
     | 
    
         
            +
                    toaster["conditions"].split(",").each do |pre_condition|
         
     | 
| 
      
 198 
     | 
    
         
            +
                      db.execute("select * from butters where id = #{pre_condition}") do |condition|
         
     | 
| 
      
 199 
     | 
    
         
            +
                        puts "\n\tID:\t\t" + condition["id"]
         
     | 
| 
      
 200 
     | 
    
         
            +
                        puts "\tName:\t\t" + condition["name"]
         
     | 
| 
      
 201 
     | 
    
         
            +
                        puts "\tFunction:\t" + condition["function"]
         
     | 
| 
      
 202 
     | 
    
         
            +
                        puts "\tOutcome:\t" + condition["outcome"]
         
     | 
| 
      
 203 
     | 
    
         
            +
                      end
         
     | 
| 
      
 204 
     | 
    
         
            +
                    end
         
     | 
| 
      
 205 
     | 
    
         
            +
                    puts "------------------------------------------------------------\n"
         
     | 
| 
      
 206 
     | 
    
         
            +
                  end
         
     | 
| 
      
 207 
     | 
    
         
            +
                end
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
       182 
209 
     | 
    
         
             
              end
         
     | 
| 
       183 
210 
     | 
    
         | 
| 
       184 
211 
     | 
    
         
             
            end
         
     |