--Sig_/WRGJF7X3_7shXUvp_yskaNm
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

On Mon, 9 Jul 2012 00:28:41 +0900
Joshua Muheim <lists / ruby-forum.com> wrote:

> This may be a very beginner's question, but I just don't get it. This
> works:
>=20
>   module MyModule
>     class MyClass
>       def file_colon_line(*arg)
>         MyModule::MyClass::textmate_colon_line(old_file_colon_line)
>       end
>=20
>       def self.textmate_colon_line(file_colon_line)
>         # ...
>       end
>     end
>   end
> end
>=20
> But I'd rather just use self when calling text_mate_colon_line like
> this:
>=20
> self::textmate_colon_line(old_file_colon_line)
>=20
> But this doesn't work (method not found). What's the right way to do
> it?

`self` always points current scope. so, to call class method from the
instance method, use `self.class.method_name`:

  module MyModule
    class MyClass
      def file_colon_line(*arg)
        self.class.textmate_colon_line(old_file_colon_line)
      end

      def self.textmate_colon_line(file_colon_line)
        # ...
      end
    end
  end



--=20
Sincerely yours,
Aleksey V. Zapparov A.K.A. ixti
FSF Member #7118
Mobile Phone: +34 677 990 688
Homepage: http://www.ixti.net
JID: zapparov / jabber.ru

*Origin: Happy Hacking!

--Sig_/WRGJF7X3_7shXUvp_yskaNm
Content-Type: application/pgp-signature; name=signature.asc
Content-Disposition: attachment; filename=signature.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQEcBAEBAgAGBQJP+aiFAAoJEGRO9nGLm9Y8FbwH/2w/SpKOJTyod4ltmxAxVG2e
AtGK8t0xsVi1t98zaSEp7OffPVHnyFjNSEOP2bKF+TqG9AeLFSkD78WJdeTmK0bM
uhjpm8GvZGKVUKrPnhCNosrHNaWA3GggOyNnixSPNdfXWQpDVxgF3ZRpXGC5deaF
ggM4A1mICzoznqN1G7A9wyq7A2UD1VxRV4b3EIR9446YFnVI3h+zg3Mj4qHZSwng
/9qzCicsI+ZIE8AGncwRT2N695AYCexA54B7hta0xwSIOqJG5H5eahSMws5wIXuG
3XRAxEFLq6wcBHScX42lBr27S5ZLQBm8+njjVMtFG5vVUUeu2CmKO4oa16EOvzM=
=/XIO
-----END PGP SIGNATURE-----

--Sig_/WRGJF7X3_7shXUvp_yskaNm--

On Mon, 9 Jul 2012 00:28:41 +0900
Joshua Muheim <lists / ruby-forum.com> wrote:

> This may be a very beginner's question, but I just don't get it. This
> works:
>=20
>   module MyModule
>     class MyClass
>       def file_colon_line(*arg)
>         MyModule::MyClass::textmate_colon_line(old_file_colon_line)
>       end
>=20
>       def self.textmate_colon_line(file_colon_line)
>         # ...
>       end
>     end
>   end
> end
>=20
> But I'd rather just use self when calling text_mate_colon_line like
> this:
>=20
> self::textmate_colon_line(old_file_colon_line)
>=20
> But this doesn't work (method not found). What's the right way to do
> it?

`self` always points current scope. so, to call class method from the
instance method, use `self.class.method_name`:

  module MyModule
    class MyClass
      def file_colon_line(*arg)
        self.class.textmate_colon_line(old_file_colon_line)
      end

      def self.textmate_colon_line(file_colon_line)
        # ...
      end
    end
  end



--=20
Sincerely yours,
Aleksey V. Zapparov A.K.A. ixti
FSF Member #7118
Mobile Phone: +34 677 990 688
Homepage: http://www.ixti.net
JID: zapparov / jabber.ru

*Origin: Happy Hacking!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQEcBAEBAgAGBQJP+aiFAAoJEGRO9nGLm9Y8FbwH/2w/SpKOJTyod4ltmxAxVG2e
AtGK8t0xsVi1t98zaSEp7OffPVHnyFjNSEOP2bKF+TqG9AeLFSkD78WJdeTmK0bM
uhjpm8GvZGKVUKrPnhCNosrHNaWA3GggOyNnixSPNdfXWQpDVxgF3ZRpXGC5deaF
ggM4A1mICzoznqN1G7A9wyq7A2UD1VxRV4b3EIR9446YFnVI3h+zg3Mj4qHZSwng
/9qzCicsI+ZIE8AGncwRT2N695AYCexA54B7hta0xwSIOqJG5H5eahSMws5wIXuG
3XRAxEFLq6wcBHScX42lBr27S5ZLQBm8+njjVMtFG5vVUUeu2CmKO4oa16EOvzM=
=/XIO
-----END PGP SIGNATURE-----