# Void value expression

**URL:** <https://www.ruby-forum.com/t/void-value-expression/120474>\
**Category:** Ruby\
**Created:** [November 17, 2007, 9:58am UTC](https://www.ruby-forum.com/t/void-value-expression/120474 "2007-11-17T09:58:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wpvanpaassen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/6f9a4e/32.png) [@wpvanpaassen](https://www.ruby-forum.com/u/wpvanpaassen)\
**Post date:** [November 17, 2007, 9:58am UTC](https://www.ruby-forum.com/t/void-value-expression/120474/1 "2007-11-17T09:58:15Z")

</div>

I’m a Ruby & OO newbie, so please bear with me. I wrote a Ruby script  
that works, but it is written in a “procedural” way as opposed to OO.  
I’m now trying to convert it to OO principles, but am having a tough  
time. I’m getting the following error when I run the program. Can  
anyone give me an idea of what might be the problem? (I know that some  
methods only contain placeholder comments, but I don’t think that should  
be the cause of the problem.) Any help is really appreciated!

1 #!/usr/bin/ruby  
2 class Record  
3 def initialize (record\_string)  
4 @record = record\_string  
5 end  
6  
7 def fix\_volume\_label  
8 # TODO: apply processing to @record to fix volume label  
9 # if required for this record  
10 end  
11  
12 def fix\_extension\_case  
13 # TODO: apply processing to @record to fix volume file  
extension  
14 # case if required for this record  
15 end  
16  
17 def to\_str  
18 @record  
19 end  
20  
21 end  
22  
23 class FixOpt  
24 def initialize  
25  
26 @argv = $\*  
27 @header\_regex = /BegBates,Volume,Path/  
28 @in\_file = nil  
29 @out\_file = nil  
30  
31 unless arguments\_valid? @argv  
32 usage  
33 exit -1  
34 end  
35  
36 begin  
37 @in\_file.open argv[0]  
38 rescue IOError  
39 @in\_file.close  
40 puts “error opening input file, terminating”  
41 exit -1  
42 end  
43  
44 end  
45  
46 def run  
47 begin  
48 @in\_file.each |record\_line|  
49 next if record\_line =~ @header\_regex  
50 record = Record.new(line)  
51 record.fix\_volume\_label  
52 record.fix\_extension\_case  
53 puts record #same as puts record.to\_str  
54 end  
55 rescue IOError  
56 @in\_file.close  
57 puts “error reading from input file, terminating”  
58 exit -1  
59 end  
60 @in\_file.close  
61 exit 0  
62 end  
63  
64 :private  
65  
66 def arguments\_valid? (argv)  
67 # validate argv[0] is a file and we have permission to open  
68 end  
69  
70 def usage  
71 # print usage  
72 end  
73  
74 #end  
75  
76 fix\_opt = FixOpt.new  
77 fix\_opt.run

---

<div class="post-metadata">

**Author:** ![wpvanpaassen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/6f9a4e/32.png) [@wpvanpaassen](https://www.ruby-forum.com/u/wpvanpaassen)\
**Post date:** [November 17, 2007, 10:12am UTC](https://www.ruby-forum.com/t/void-value-expression/120474/2 "2007-11-17T10:12:58Z")

</div>

Peter V. wrote:

> Â 48 Â Â Â Â Â Â @in\_file.each |record\_line|  
> ^^  
> @in\_file.each do |record\_line|

HTH,  
Sebastian

---

<div class="post-metadata">

**Author:** ![wpvanpaassen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/6f9a4e/32.png) [@wpvanpaassen](https://www.ruby-forum.com/u/wpvanpaassen)\
**Post date:** [November 17, 2007, 10:26am UTC](https://www.ruby-forum.com/t/void-value-expression/120474/3 "2007-11-17T10:26:20Z")

</div>

Sebastian,  
Thank you so much! Believe it or not, I had noticed the missing do when  
I left the office about 12 hours ago, but forgot about it when I got  
home. Another pair of eyes this late sure helps!  
PETERV

Sebastian H. wrote:

> Peter V. wrote:
> 
> > 48 @in\_file.each |record\_line|  
> > ^^  
> > @in\_file.each do |record\_line|
> 
> HTH,  
> Sebastian
