Forum: Ruby nubie question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
0352333a04ba33c6ef60e87eb8282b7a?d=identicon&s=25 Mac Pat (Guest)
on 2007-07-30 00:05
(Received via mailing list)
I am trying to learn Ruby and I have read the picax book at least twice
seems to understand most of what is said in the book. Now I am reading
through some of the code written that I down loaded. I saw some code
that I
wanted someone to explain to me.

module HL7 # :nodoc:
  VERSION = "0.1.%s" % "$Rev: 23 $".gsub(/\$Rev:\s+/, '').gsub(/\s*\$$/,

# Encapsulate HL7 specific exceptions
class HL7::Exception < StandardError

# Parsing failed
class HL7::ParseError < HL7::Exception

Explain to me how to use the "::" operator. It seems the author is
a Class called HL7::Exception? The syntax for class definition is Class

15a5043475dac9278ae75efb4c71f1f6?d=identicon&s=25 Felix Windt (Guest)
on 2007-07-30 01:09
(Received via mailing list)
> explain to me.
> # Parsing failed
> Thanksl

Check out the Pickaxe chapter on modules.


C06869c119472a139eb163b72040b0db?d=identicon&s=25 Bertram Scharpf (Guest)
on 2007-07-30 01:40
(Received via mailing list)

Am Montag, 30. Jul 2007, 07:04:57 +0900 schrieb Mac Pat:
> module HL7 # :nodoc:
>   VERSION = "0.1.%s" % "$Rev: 23 $".gsub(/\$Rev:\s+/, '').gsub(/\s*\$$/, '')
> end

I think smarter would be one of

  V = "0.1." + "$Rev: 23 $"[/\$Rev:\s*(\d+)\s*\$/, 1]
  V = "0.1.%d" % "$Rev: 23 $"[/\d+/]
  V = [0,1,"$Rev: 23 $"[/\d+/]].join "."

To get it readable to some slight extent one should split it
up into at least two lines.

  tiny = "$Rev: 23 $"[/\d+/]

> # Encapsulate HL7 specific exceptions
> class HL7::Exception < StandardError
> end

  module HL7 ; class Exception < ::StandardError ; end ; end

This topic is locked and can not be replied to.