printing from a file - beginner

  • Thread starter Johnathan Smith
  • Start date
J

Johnathan Smith

hi there

im new to ruby and ive got a bit of a problem

basically i have a text file and i want my ruby class to perform a
regular expression to count the lines with a Tag in the text file

if anyone could offer any help or psuedo code id be very appreciative

my code is below
many thanks

text file:

Tag: ref1
Type: Book
Author: Little, S R

Tag: ref2
Type: Journal
Author: Smith, J

ruby code:

#
require 'getoptlong'

opts = GetoptLong.new(
['--style', '-n', GetoptLong::NO_ARGUMENT ],
['--database', '-i', GetoptLong::REQUIRED_ARGUMENT]
)
opts.each do |opt, arg|
case opt
when '--style'
require arg
when '--database'
end
end
#
#
#
# process options
#
#
#
File.open('reference.txt').each do |line|
# puts line
Regexp.new
end
#
#
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top