christiank-turntable 0.6.2 → 0.6.3

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 +12 -7
  2. metadata +2 -2
data/turntable.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #
2
- # turntable v0.6.2
2
+ # turntable v0.6.3
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.2'
11
+ @@version = 'v0.6.3'
12
12
 
13
13
  # Creates a new Turntable database.
14
14
  def initialize filename, *columns
@@ -41,7 +41,7 @@ class Turntable < Array
41
41
 
42
42
  # Reader methods for this Turntable's metadata.
43
43
  def Turntable.version; @@version; end
44
- attr_reader :columns, :filename
44
+ attr_reader :filename, :columns
45
45
 
46
46
  # Inserts a new column to the database. Fills all the pre-existing rows with
47
47
  # nil. Returns the new database.
@@ -77,6 +77,11 @@ class Turntable < Array
77
77
  row
78
78
  end
79
79
 
80
+ # Custom inspect() makes working in IRB much cleaner.
81
+ def inspect
82
+ "#<#{self.class}:#{self.object_id} @filename=#{self.filename.inspect}, @columns=#{self.columns.inspect}>"
83
+ end
84
+
80
85
  # Prints the entire database to STDOUT. It's just a wrapper for
81
86
  # Array#to_stdout.
82
87
  def to_stdout
@@ -108,10 +113,10 @@ class Array
108
113
 
109
114
  # Prints an array of rows to STDOUT.
110
115
  def to_stdout
116
+ self.first.table.each_key { |column| print "|_.#{column}" }
117
+ puts '|'
111
118
  self.each do |row|
112
- row.table.each_value do |value|
113
- print "|#{value}"
114
- end
119
+ row.table.each_value { |value| print "|#{value}" }
115
120
  puts '|'
116
121
  end
117
122
  nil
@@ -121,8 +126,8 @@ end
121
126
 
122
127
  # Rows are custom OpenStructs, based on dictionaries and not hashes.
123
128
  class Row < OpenStruct
124
- public :table
125
129
  def initialize; @table = Dictionary.new; end
130
+ public :table
126
131
  end
127
132
 
128
133
  # Turn off Object#id warnings.
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.2
4
+ version: 0.6.3
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-16 00:00:00 -07:00
12
+ date: 2009-06-17 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15