christiank-turntable 0.6 → 0.6.1

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 +7 -5
  2. metadata +1 -1
data/turntable.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # turntable v0.6
2
+ # turntable v0.6.1
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'
11
+ @@version = 'v0.6.1'
12
12
 
13
13
  # Creates a new Turntable database.
14
14
  def initialize filename, *columns
@@ -23,6 +23,8 @@ class Turntable < Array
23
23
  end
24
24
 
25
25
  # Loads an existing Turntable.
26
+ # TODO: @filename isn't being set to the new filename because it's
27
+ # Marshalling back the old @filename.
26
28
  def Turntable.load filename
27
29
  @filename = File.expand_path(filename)
28
30
  f = File.open @filename
@@ -30,8 +32,8 @@ class Turntable < Array
30
32
  end
31
33
 
32
34
  # Reader methods for this Turntable's metadata.
35
+ def Turntable.version; @@version; end
33
36
  attr_reader :filename, :columns
34
- def version; @@version; end
35
37
 
36
38
  # Inserts a new column to the database. Fills all the pre-existing rows with
37
39
  # nil. Returns the new database.
@@ -54,11 +56,11 @@ class Turntable < Array
54
56
  # number of arguments passed in equal the number of columns in the database.
55
57
  def insert *args
56
58
  if args.length != @columns.length
57
- raise ArgumentError, "wrong number of arguments (#{args.length} for #{@columns.length})"
59
+ raise ArgumentError, "wrong number of arguments (#{args.length} for #{@columns.length})"
58
60
  end
59
61
 
60
62
  row = Row.new
61
- row.id = self.length
63
+ self.empty? ? (row.id = 0) : (row.id = self.last.id + 1)
62
64
 
63
65
  @columns.each { |column| eval "row.#{column} = args.shift" }
64
66
 
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
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Koch