christiank-turntable 0.6.4.1 → 0.6.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/turntable.rb +14 -5
  2. metadata +2 -2
data/turntable.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # turntable v0.6.4.1
2
+ # turntable v0.6.4.2
3
3
  # Christian Koch <ckoch002@student.ucr.edu>
4
4
  #
5
5
 
@@ -8,7 +8,7 @@ require 'ostruct'
8
8
 
9
9
  class Turntable < Array
10
10
 
11
- @@version = 'v0.6.4.1'
11
+ @@version = 'v0.6.4.2'
12
12
 
13
13
  @@insert_proc = %q(
14
14
  if args.length != @columns.length
@@ -19,7 +19,8 @@ class Turntable < Array
19
19
  @columns.each { |column| eval "row.#{column} = args.shift" }
20
20
  self.push row
21
21
  self.save_to @filename
22
- row)
22
+ row
23
+ )
23
24
 
24
25
  # Creates a new Turntable database. Accepts either a list of column names, or
25
26
  # an array of symbols which contain the same thing.
@@ -77,17 +78,25 @@ class Turntable < Array
77
78
  (before_table - what_wasnt_deleted).first
78
79
  end
79
80
 
81
+ # Returns a boolean, indicating whether the select statement would return
82
+ # any data.
83
+ def include?
84
+ result = []
85
+ self.each { |row| result.push(row) if yield(row) }
86
+ result.any?
87
+ end
88
+
80
89
  # Pushes self with a new row. Returns the newly created row. Requires the
81
90
  # number of arguments passed in equal the number of columns in the database,
82
91
  # or it can accept calls from Turntable#insert_array.
83
92
  def insert *args
84
93
  eval @@insert_proc
85
94
  end
86
-
95
+
87
96
  # Same as Turntable#insert, except this method accepts only one array filled
88
97
  # with values.
89
98
  def insert_array args
90
- raise ArgumentError, 'Turntable#insert_array requires an array' unless args.is_a?(Array)
99
+ raise ArgumentError, 'Turntable#insert_array requires one array' unless args.is_a?(Array)
91
100
  eval @@insert_proc
92
101
  end
93
102
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: christiank-turntable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4.1
4
+ version: 0.6.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Koch
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-18 00:00:00 -07:00
12
+ date: 2009-06-24 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15