class PresentClass
PresentClass
should behave just as NilClass, but the opposite. It represents that a value exists but does not represent any specific vallue or type; it is ambiguous. present should be seen as the opposite of nil.
Attributes
type[R]
Public Class Methods
new(type = nil)
click to toggle source
type
should be either nil (for ambiguous) or the class of the object represented.
# File lib/tektite_ruby_utils/present.rb, line 9 def initialize(type = nil) @type = type end
Public Instance Methods
inspect()
click to toggle source
Makes present appear and behave like nil in the console. To see the object id, use .object_id
. To see the value of an attribute such as +@type+, use the attribute getter method, such as .type.
# File lib/tektite_ruby_utils/present.rb, line 16 def inspect 'present' end
to_a()
click to toggle source
present can not be converted to an Array
.
# File lib/tektite_ruby_utils/present.rb, line 30 def to_a raise AmbiguousValueError end
to_i()
click to toggle source
present can not be converted to an Integer.
# File lib/tektite_ruby_utils/present.rb, line 25 def to_i raise AmbiguousValueError end
to_s()
click to toggle source
present can not be converted to a String.
# File lib/tektite_ruby_utils/present.rb, line 35 def to_s raise AmbiguousValueError end
type_known?()
click to toggle source
Return true if the object type is defined.
# File lib/tektite_ruby_utils/present.rb, line 40 def type_known? @type.nil? ? false : true end