Class: Card::ViewName
Constant Summary collapse
- @@name2viewnameobject =
{}
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(str) ⇒ ViewName
constructor
A new instance of ViewName.
- #simple_key ⇒ Object
- #to_viewname ⇒ Object
Constructor Details
#initialize(str) ⇒ ViewName
Returns a new instance of ViewName.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/card/view_name.rb', line 22 def initialize str @s = str.to_s.strip @s = @s.encode('UTF-8') if RUBYENCODING @key = if @s.index(self.class.joint) @parts = @s.split(/\s*#{JOINT_RE}\s*/) @parts << '' if @s[-1, 1] == self.class.joint @simple = false @parts.map { |p| p.to_name.key } * self.class.joint else @parts = [str] @simple = true str.empty? ? '' : simple_key end @@name2viewnameobject[str] = self end |
Class Method Details
.new(obj) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/card/view_name.rb', line 11 def new obj return obj if self.class === obj str = Array === obj ? obj * joint : obj.to_s if known_name = @@name2viewnameobject[str] known_name else super str.strip end end |