On Feb 27, 7:33 pm, Gregory Seidman <gsslist+r...@anthropohedron.net> wrote:
On Thu, Feb 28, 2008 at 04:24:58AM +0900, aidy wrote:
> All I want it to read this YAML as a ruby hash and place into the
> below methods. Could someone help?
Thanks for you help but I am having trouble losing the hash value when
calling the method
I don't know what you mean by that.
one.rb
def SmokeTest.create_from_yaml_file(filename)
data = YAML.load_file(filename)
obj = new(data['test'], data['url'])
obj.register(data['first_name'], data['surname'], data['email'],
data['password'], data['registration'])
end
[...]
This is incorrect. You are missing the last line from the method I
originally wrote, which is just obj. If you don't have that, the
create_from_yaml method returns whatever obj.register returns, rather than
the created object itself. This may be the problem you are having.
Cheers
Aidy
--Greg
···
On Thu, Feb 28, 2008 at 10:04:57PM +0900, aidy wrote:
> test: tiscali
> url: ?http://tiscali3-test.vizumi.com/
> register:
> ? first_name: aidy
> ? surname: smith
> ? email: 'testautomat...@googlemail.com'
> ? password: password
> ? registration: KJHDF123
>
The problem is I am trying to use nested mapping. I have commented out
register.
Ah, yes, that would do it. Sorry, I missed that.
Aidy
--Greg
···
On Fri, Feb 29, 2008 at 01:09:55AM +0900, aidy wrote:
2. And how can you get away with instantiating here.
obj = new(data['test'], data['url'])
Well, it's sort of a constructor built on top of the standard constructor
(new). It certainly belongs to the class, since it is building an object of
that class, and because it is a method of that class object, it can call
new without fully qualifying it (i.e. SmokeTest.new).
Remember that there is nothing terribly special about the new method. I
believe it does nothing more than call alloc (to get an uninitialized
object of the class) then call initialize on that object. (I'm sure I will
be corrected if there is more to it than that.) Likewise, there
is nothing special about the initialize function. By convention (and
default implementation), it is called by the class new method, but it's
just a method like any other.
All I did was write a new constructor for your class, wrapping the default
constructor.
Cheers
Aidy
--Greg
···
On Mon, Mar 03, 2008 at 10:49:54PM +0900, aidy wrote:
On 28 Feb, 20:40, Gregory Seidman <gsslist+r...@anthropohedron.net> > wrote:
> On Fri, Feb 29, 2008 at 01:09:55AM +0900, aidy wrote: