Module: Naming
- Defined in:
- lib/naming.rb,
lib/naming/meta.rb,
lib/naming/version.rb,
lib/naming/name-set.rb
Overview
Naming is a module for generating naming classes that consist by name and value. Naming classes are generated dynamically when you refer it.
Defined Under Namespace
Constant Summary collapse
- VERSION =
version of this library
"0.1.0"
Class Method Summary collapse
-
.[](*names) ⇒ NameSet
Return the name set object.
-
.const_missing(name) ⇒ Object
private
Generate a new naming class.
-
.method_missing(name, *args) ⇒ Object
private
Generate a new naming class and call the constructor with value.
-
.others(array) ⇒ Object
Collect objects from the array excluding naming objects.
Class Method Details
.[](*names) ⇒ NameSet
Return the name set object.
102 103 104 |
# File 'lib/naming.rb', line 102 def [](*names) NameSet.new(*names) end |
.const_missing(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Generate a new naming class.
69 70 71 72 73 74 75 76 77 |
# File 'lib/naming.rb', line 69 def const_missing(name) cls = Class.new(Meta) self.singleton_class.class_exec do define_method(name) do |value| cls.new(value) end end const_set(name, cls) end |
.method_missing(name, *args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Generate a new naming class and call the constructor with value.
61 62 63 64 |
# File 'lib/naming.rb', line 61 def method_missing(name, *args) const_get(name) send(name, *args) end |
.others(array) ⇒ Object
Collect objects from the array excluding naming objects.
93 94 95 |
# File 'lib/naming.rb', line 93 def others(array) array.select{|elt| not(elt.kind_of?(Meta))} end |