All,

A case of http://www.sjbaker.org/humor/cardboard_dog.html - I downgraded to
Ruby 2.1.5p273 and exactly the same code works, so I suspect a bug in
2.2.0p0.

I can continue on 2.1.5p273 as there's nothing in 2.2.0p0 I absolutely need
- just putting this out there for anyone who might have a similar problem.


Peter


On 16 March 2015 at 22:05, Peter Hicks <peter.hicks / poggs.co.uk> wrote:

> All,
>
> I can't explain this behaviour, and I'm reasonably sure it's not a bug and
> it's something subtle that I've missed.
>
> I'm on Ruby 2.2.0p0.  I have a class called 'App::TrainStatus', which has
> an initialize method defined which prints a single-line string for
> debugging.  I have a second class, 'App::TrainFactory', which takes an XML
> message and, depending on the content of the XML, returns one of a number
> of classes.
>
> The problem I have is that App::TrainStatus.new returns nil from within
> TrainFactory:
>
>   def self.parse_message(msg)
>     return App::TrainStatus.new
>   end
>
> If I change App::TrainStatus to another class which I haven't defined,
> e.g. App::Foobar, I get an appropriate error.
>
> If I insert the following line in to the code:
>
>   puts App::TrainStatus
>
> ...then I get App::TrainStatus returned.  If I put ".class" at the end, I
> get "Class" returned - so it seems as though the class is loaded and
> available.
>
> What's puzzling me is that the TrainStatus class is loaded and available,
> but a call to 'new' doesn't do anything - it doesn't even print the debug
> message in the initialize() method of the class.
>
> Can anyone give me some hints on troubleshooting?
>
>
> Peter
>
>


-- 
Peter Hicks  |  Poggs Consultancy Services  |  t: 020 3095 2600  |  m:
07970 476447