Class: Object
- Inherits:
- BasicObject
- Includes:
- KKernel
- Defined in:
- lib/kyanite/general/object.rb,
lib/kyanite/set.rb,
lib/kyanite/general/kernel.rb,
lib/kyanite/enumerable/structure.rb
Overview
Instance Method Summary collapse
-
#blank? ⇒ false
Returns
false. -
#deep_copy ⇒ Object
Slow but in-depth alternative to
dup. -
#empty? ⇒ false
Returns
false. - #is_collection? ⇒ false
-
#is_numeric? ⇒ Boolean
Is the object numeric? Tests see here.
-
#name_of_constant(wert_der_konstanten) ⇒ Object
Findet den Namen einer Ruby-Konstanten anhand seines Wertes.
-
#respond(sym, *args) ⇒ Object
Like
respond_to?but returns the result of the call if it does indeed respond. -
#to_set ⇒ Set
Returns Set with one element.
Methods included from KKernel
#repeat_n_seconds, #silence_warnings
Instance Method Details
#blank? ⇒ false
Returns false
15 16 17 |
# File 'lib/kyanite/general/object.rb', line 15 def blank? false end |
#deep_copy ⇒ Object
Slow but in-depth alternative to dup. Also duplicates sub-objects. Is e.g. for undo operations used, see module Undoable.
30 31 32 |
# File 'lib/kyanite/general/object.rb', line 30 def deep_copy Marshal.load( Marshal.dump( self ) ) end |
#empty? ⇒ false
Returns false
46 47 48 |
# File 'lib/kyanite/general/object.rb', line 46 def empty? false end |
#is_collection? ⇒ false
26 |
# File 'lib/kyanite/enumerable/structure.rb', line 26 def is_collection?; false; end |
#is_numeric? ⇒ Boolean
Is the object numeric? Tests see here.
38 39 40 41 42 |
# File 'lib/kyanite/general/object.rb', line 38 def is_numeric? Float self rescue #Exception => e false end |
#name_of_constant(wert_der_konstanten) ⇒ Object
Findet den Namen einer Ruby-Konstanten anhand seines Wertes. Funktioniert so nicht. Seltsamersweise funktioniert es aber, wenn man den Quelltext dieser Methode direkt ausführt. Verwendet in der Info-Ansicht des Scaffoldings.
57 58 59 |
# File 'lib/kyanite/general/object.rb', line 57 def name_of_constant(wert_der_konstanten) Object.constants.find { |c| Object.const_get(c) == wert_der_konstanten} end |
#respond(sym, *args) ⇒ Object
Like respond_to? but returns the result of the call if it does indeed respond. See Facets Kernel#respond.
23 24 25 26 |
# File 'lib/kyanite/general/object.rb', line 23 def respond(sym, *args) return nil if not respond_to?(sym) send(sym, *args) end |