Module: Kernel
- Defined in:
- lib/cuts/cut.rb
Instance Method Summary collapse
-
#cut(klass, &block) ⇒ Object
Cut convenience method.
Instance Method Details
#cut(klass, &block) ⇒ Object
Cut convenience method.
cut :Z < X do
def x; '{' + super + '}'; end
end
With a name, the cut is made a constant of the module it is defined in, or of Object at the toplevel. Without one, as in cut(X), it is anonymous.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/cuts/cut.rb', line 137 def cut(klass, &block) case klass when Array name, klass = *klass else name = nil end cut = Cut.new(klass, &block) mod = (Module === self ? self : Object) mod.const_set(name, cut) if name # <<- this is what we don't have in Cut.new return cut end |