From: Quintus Date: 2012-04-18T00:35:19+09:00 Subject: Re: Capital Cyrillic letter in Ruby class name (UTF-8) -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 17.04.2012 17:05, schrieb Vladimir Kerimov: > I need a simple way to make classes like this: class Документ. It’s perfectly possible. irb(main):001:0> Документ = Class.new => # irb(main):002:0> obj = Документ.new => #<#:0x00000001b57e48> You may want to overwrite the class’ ::inspect method to display properly in IRB. But note that it is regarded as a local variable rather than a constant; you could use a namespace module with module methods (which can be called using the :: syntax) to achieve what you want, i.e. something like ========================= module Namespace X = Class.new def X.inspect; "Документ"; end def X.name; "Документ"; end def self.Документ X end end obj = Namespace::Документ.new ========================= Note that I assign the new class to a separate constant (X) instead of just returning Class.new in the Namespace::Документ() method, because this would return a new class each time you call it (making checks with #kind_of? useless). However, using local names doesn’t seem a good idea to me altogether, most programming languages are inspired by English and mixing it with another language makes it look weird. Even worse, a framework like Rails expects English nouns to be used as classnames, because it automatically derives a whole bunch of further names from it by inflecting the word according to English grammar rules. Local names break such frameworks completely. This obviously requires Ruby 1.9. Vale, Marvin -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJPjY1TAAoJELh1XLHFkqhaQNgH/2P53eA0VeZEwzugtQGr4qHz 9Y2mcOYzVDkpOReCwMbN28FJ/jqrhDwjjPfsLqQKUi2ApxCCeRMWyhII96AA+Y7g VXw3uipwTol+1EzWVoCXkBDHrLuKxqEDcSD28FGoL95EnO2uF9w2YnVOG8ctFtpA QO8hxxCGsng2UxuPRCUVKbCXroz07AnEx6MD/bKcg27eVvycm11yP5yxnJQdFjay ZvRfHAiCXBb63ImOu613+/ZG8Itx7kXr/1lnjZOnHpt9dKGClmN35crrON/wDDfD 1do7W3OlNNTJ7ZbzJ5CZ2jnAX7lKzAduBF77608Nup2bzhFoVyQ8C+dqX2rJdcg= =Lx2r -----END PGP SIGNATURE-----