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
Object Additions
- Kyanite tests and examples
- Usage
-
require 'kyanite/basics'
Instance Method Summary (collapse)
-
- (false) blank?
Returns false.
-
- (Object) deep_copy
Slow but in-depth alternative to dup.
-
- (false) empty?
Returns false.
- - (false) is_collection?
-
- (Boolean) is_numeric?
Is the object numeric? Tests see here.
-
- (Object) name_of_constant(wert_der_konstanten)
Findet den Namen einer Ruby-Konstanten anhand seines Wertes.
-
- (Object) repeat_n_seconds(n = 1, &block)
Repeats a block until the time is up.
-
- (Object) respond(sym, *args)
Like respond_to? but returns the result of the call if it does indeed respond.
-
- (Object) silence_warnings
Silence all Ruby warnings for the following block.
-
- (Set) to_set
Returns Set with one element.
Instance Method Details
- (false) blank?
Returns false
15 16 17 |
# File 'lib/kyanite/general/object.rb', line 15 def blank? false end |
- (Object) deep_copy
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 |
- (false) empty?
Returns false
46 47 48 |
# File 'lib/kyanite/general/object.rb', line 46 def empty? false end |
- (false) is_collection?
26 |
# File 'lib/kyanite/enumerable/structure.rb', line 26 def is_collection?; false; end |
- (Boolean) is_numeric?
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 |
- (Object) name_of_constant(wert_der_konstanten)
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 |
- (Object) respond(sym, *args)
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 |