Iñaki Baz Castillo
5/3/2008 9:41:00 AM
El S=C3=A1bado, 3 de Mayo de 2008, David A. Black escribi=C3=B3:
> > So "hdr_from" is like a pointer to header("From"), but it's not valid f=
or
> > me since I need the possibility of doing a re-assignement:
> >
> > =C2=A0header("From") =3D header("To")
>
> That's not legal Ruby. A method call isn't an lvalue.
Oh, yes, you are right!
Please, let me know if I understand correctly why:
header("From") returns a value so I'm trying to do:
value1 =3D value2
that is not legal, is it?
> My advice is to try to learn to think in Ruby, so that you don't keep
> experiencing frustration because of what you perceive Ruby as not
> having. Believe me, Ruby is definitely feature-rich enough to parse
> headers :-)
Well, in fact I've already done the parser (using TreeTop magic). But it's =
not=20
enought with parsing headers (as it would be in HTTP protocol) since I'm=20
doing a SIP stack and it can be a proxy (so some headers are modified, new=
=20
added, some deleted... and the rest of message remains equal and is forward=
ed=20
to other server.
That's why I need an efficient way of accessing the @header array of Header=
=20
objets, parse just one of them and keep the whole message as it arrived.
> A lot of Ruby objects need to change their state or contents, without
> changing what object they are. Methods like Array#replace,
> String#replace, and many others, do exactly that. Maybe your message
> objects could "replace" headers with each other, or something like
> that.
Ok, so you mean that I should avoid using "=3D" and use objects methods to=
=20
replace their content. Nice to know.
Thanks a lot.
=2D-=20
I=C3=B1aki Baz Castillo