On Wed, Oct 5, 2011 at 9:27 PM, Kassym Dorsel <k.dorsel / gmail.com> wrote:
> I have this :
> =A0def profile
> =A0 =A0page =3D @agent.get(@uri)
> =A0 =A0MultiJson.decode(page.body.gsub(/([a-zA-Z]+):/, '"\1":')) do |file=
|
> =A0 =A0 =A0if file['errCode'] =3D=3D 0
> =A0 =A0 =A0 =A0return file['miniprofile']
> =A0 =A0 =A0else
> =A0 =A0 =A0 =A0return
> {'errCode'=3D>file['errCode'],'errText'=3D>file['errText'],'uri'=3D>page.=
uri}
> =A0 =A0 =A0end
> =A0 =A0 =A0end
> =A0end
>
> This always returns the MultiJson output. (not what I want) It seems as
> if it doesn't even
> do the block. If I use a variable like this :
>
> =A0def profile
> =A0 =A0page =3D @agent.get(@uri)
> =A0 =A0file =3D MultiJson.decode(page.body.gsub(/([a-zA-Z]+):/, '"\1":'))
> =A0 =A0 =A0if file['errCode'] =3D=3D 0
> =A0 =A0 =A0 =A0return file['miniprofile']
> =A0 =A0 =A0else
> =A0 =A0 =A0 =A0return
> {'errCode'=3D>file['errCode'],'errText'=3D>file['errText'],'uri'=3D>page.=
uri}
> =A0 =A0 =A0end
> =A0end
>
> It returns one or the other inside the if statements.
>
> Shouldn't both of these return the same thing

It depends on what MultiJson.decode does with the block that you are
passing to it.
Can you show us that code?
It might be that the decode method is just not doing anything with the
block (doesn't yield or call it), that could explain the behaviour you
are seeing.

Jesus.