Class: Wx::Variant
- Includes:
- Enumerable
- Defined in:
- lib/wx/doc/gen/variant.rb,
lib/wx/doc/variant.rb
Overview
This class is untracked and should not be derived from nor instances extended!
The Variant class represents a container for any type.
A variant’s value can be changed at run time, possibly to a different type of value. In wxRuby Wx::Variant is the only available Wx variant class (unlike in C++) and almost exclusively for use in combination with the property grid classes (see the PG module).
By default Wx::Variant can store values of type bool, Integer, Float, String, Time (or Date / DateTime), Array of String, Array of Variant, Font, Colour and ColourPropertyValue. In addition Wx::Variant can store any Ruby Object.
An optional name member is associated with a Wx::Variant.
In wxRuby Wx::Variant also provides the standard conversion methods #to_i, #to_s and #to_f for supported value types. In case of incompatible value types these methods will raise a TypeError exception.
Instance Method Summary collapse
- #==(*args) ⇒ Object
-
#append(value) ⇒ void
Appends a value to the list.
-
#array_string? ⇒ true, false
Checks if Variant contains an ArrayString (array of String) value (not null).
-
#assign(*args) ⇒ Object
(also: #<<)
Replaces the value of the current variant with the given value.
-
#bool? ⇒ true, false
Checks if Variant contains a boolean value (not null).
-
#clear ⇒ void
Makes the variant null by deleting the internal data and set the name to EmptyString.
-
#clear_list ⇒ void
Deletes the contents of the list.
-
#clone ⇒ Wx::Variant
Calls #dup.
-
#colour? ⇒ true, false
Checks if Variant contains a Colour value (not null).
-
#colour_property_value? ⇒ true, false
Checks if Variant contains a ColourPropertyValue value (not null).
-
#date_time? ⇒ true, false
Checks if Variant contains a (wx)DateTime value (not null).
-
#delete(item) ⇒ Boolean
Deletes the zero-based item from the list.
-
#double? ⇒ true, false
Checks if Variant contains a double value (not null).
-
#dup ⇒ Wx::Variant
Copy constructs a Variant instance.
-
#each ⇒ Object
When a block is given iterates all items of a variant list passing each item to the block.
-
#font? ⇒ true, false
Checks if Variant contains a Font value (not null).
-
#get_array_string ⇒ Array<String>
(also: #array_string)
Returns the string array value.
-
#get_bool ⇒ Boolean
(also: #bool)
Returns the boolean value.
-
#get_char ⇒ String
(also: #char)
Returns the character value.
-
#get_colour ⇒ Wx::Colour
(also: #colour)
Returns colour value.
-
#get_colour_property_value ⇒ Wx::PG::ColourPropertyValue
(also: #colour_property_value)
Returns colour property value.
-
#get_count ⇒ Integer
(also: #count)
Returns the number of elements in the list.
-
#get_date_time ⇒ Time, ...
(also: #date_time)
Returns the date value.
-
#get_double ⇒ Float
(also: #double)
Returns the floating point value.
-
#get_font ⇒ Wx::Font
(also: #font)
Returns font value.
-
#get_long ⇒ Integer
(also: #long)
Returns the integer value.
-
#get_long_long ⇒ Integer
(also: #long_long)
Returns the signed 64-bit integer value.
-
#get_name ⇒ Wx::String
(also: #name)
Returns a constant reference to the variant name.
-
#get_object ⇒ Object
(also: #object)
Returns a pointer to the internal variant data.
-
#get_string ⇒ String
(also: #string)
Gets the string value.
-
#get_type ⇒ String
(also: #type)
Returns the value type as a string.
-
#get_u_long_long ⇒ Integer
(also: #u_long_long)
Returns the unsigned 64-bit integer value.
-
#initialize(*args) ⇒ Variant
constructor
A new instance of Variant.
-
#insert(value) ⇒ void
Inserts a value at the front of the list.
-
#integer? ⇒ true, false
Checks if Variant contains an integer value (long|long long|unsigned long long).
-
#is_null ⇒ Boolean
(also: #null?)
Returns true if there is no data associated with this variant, false if there is data.
-
#is_type(type) ⇒ Boolean
(also: #type?)
Returns true if type matches the type of the variant, false otherwise.
-
#list? ⇒ true, false
Checks if Variant contains a VariantList (array of Variant) value (not null).
-
#long? ⇒ true, false
Checks if Variant contains a long value (not null).
-
#long_long? ⇒ true, false
Checks if Variant contains a long long value (not null).
-
#make_null ⇒ void
Makes the variant null by deleting the internal data.
-
#make_string ⇒ String
Makes a string representation of the variant value (for any type).
-
#member(value) ⇒ Boolean
Returns true if value matches an element in the list.
-
#null_list ⇒ void
Makes an empty list.
-
#numeric? ⇒ true, false
Checks if Variant contains an integer value (integer | double).
-
#object?(klass = Object) ⇒ true, false
Checks if Variant contains an unspecified Ruby object (not null or nil and not one of the other value types).
-
#string? ⇒ true, false
Checks if Variant contains a String value (not null).
-
#to_f ⇒ Float
Convert contained object to floating point value if possible.
-
#to_i ⇒ Integer
Convert contained object to integer value if possible.
-
#to_s ⇒ String
Convert contained object to string value if possible.
-
#u_long_long? ⇒ true, false
Checks if Variant contains an unsigned long long value (not null).
-
#unshare ⇒ Boolean
Makes sure that any data associated with this variant is not shared with other variants.
Methods inherited from Object
Constructor Details
#initialize ⇒ Wx::Variant #initialize(data, name = ('')) ⇒ Wx::Variant #initialize(variant) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(value, name = ('')) ⇒ Wx::Variant #initialize(val, name = ('')) ⇒ Wx::Variant #initialize(val, name = ('')) ⇒ Wx::Variant
Returns a new instance of Variant.
180 |
# File 'lib/wx/doc/gen/variant.rb', line 180 def initialize(*args) end |
Instance Method Details
#==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean #==(value) ⇒ Boolean
119 |
# File 'lib/wx/doc/gen/variant.rb', line 119 def ==(*args) end |
#append(value) ⇒ void
This method returns an undefined value.
Appends a value to the list.
32 |
# File 'lib/wx/doc/gen/variant.rb', line 32 def append(value) end |
#array_string? ⇒ true, false
Checks if Variant contains an ArrayString (array of String) value (not null).
136 |
# File 'lib/wx/doc/variant.rb', line 136 def array_string?; end |
#assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self #assign(value) ⇒ self Also known as: <<
Replaces the value of the current variant with the given value
73 |
# File 'lib/wx/doc/variant.rb', line 73 def assign(*args) end |
#bool? ⇒ true, false
Checks if Variant contains a boolean value (not null).
97 |
# File 'lib/wx/doc/variant.rb', line 97 def bool?; end |
#clear ⇒ void
This method returns an undefined value.
Makes the variant null by deleting the internal data and set the name to EmptyString.
36 |
# File 'lib/wx/doc/gen/variant.rb', line 36 def clear; end |
#clear_list ⇒ void
This method returns an undefined value.
Deletes the contents of the list.
40 |
# File 'lib/wx/doc/gen/variant.rb', line 40 def clear_list; end |
#colour? ⇒ true, false
Checks if Variant contains a Colour value (not null).
149 |
# File 'lib/wx/doc/variant.rb', line 149 def colour?; end |
#colour_property_value? ⇒ true, false
Checks if Variant contains a ColourPropertyValue value (not null).
158 |
# File 'lib/wx/doc/variant.rb', line 158 def colour_property_value?; end |
#date_time? ⇒ true, false
Checks if Variant contains a (wx)DateTime value (not null). (Note that the DateTime values in question concern wxDateTime and not the Ruby DateTime class; in fact wxDateTime is normally returned as a Ruby Time value)
120 |
# File 'lib/wx/doc/variant.rb', line 120 def date_time?; end |
#delete(item) ⇒ Boolean
Deletes the zero-based item from the list.
45 |
# File 'lib/wx/doc/gen/variant.rb', line 45 def delete(item) end |
#double? ⇒ true, false
Checks if Variant contains a double value (not null).
124 |
# File 'lib/wx/doc/variant.rb', line 124 def double?; end |
#dup ⇒ Wx::Variant
Copy constructs a Variant instance.
173 |
# File 'lib/wx/doc/variant.rb', line 173 def dup; end |
#each {|item| ... } ⇒ ::Object #each ⇒ Enumerator
When a block is given iterates all items of a variant list passing each item to the block. Returns an enumerator when no block is given.
22 |
# File 'lib/wx/doc/variant.rb', line 22 def each; end |
#font? ⇒ true, false
Checks if Variant contains a Font value (not null).
140 |
# File 'lib/wx/doc/variant.rb', line 140 def font?; end |
#get_array_string ⇒ Array<String> Also known as: array_string
Returns the string array value.
184 |
# File 'lib/wx/doc/gen/variant.rb', line 184 def get_array_string; end |
#get_bool ⇒ Boolean Also known as: bool
Returns the boolean value.
189 |
# File 'lib/wx/doc/gen/variant.rb', line 189 def get_bool; end |
#get_char ⇒ String Also known as: char
Returns the character value.
194 |
# File 'lib/wx/doc/gen/variant.rb', line 194 def get_char; end |
#get_colour ⇒ Wx::Colour Also known as: colour
Returns colour value.
153 |
# File 'lib/wx/doc/variant.rb', line 153 def get_colour; end |
#get_colour_property_value ⇒ Wx::PG::ColourPropertyValue Also known as: colour_property_value
Returns colour property value.
162 |
# File 'lib/wx/doc/variant.rb', line 162 def get_colour_property_value; end |
#get_count ⇒ Integer Also known as: count
Returns the number of elements in the list.
49 |
# File 'lib/wx/doc/gen/variant.rb', line 49 def get_count; end |
#get_date_time ⇒ Time, ... Also known as: date_time
Returns the date value.
206 |
# File 'lib/wx/doc/gen/variant.rb', line 206 def get_date_time; end |
#get_double ⇒ Float Also known as: double
Returns the floating point value.
211 |
# File 'lib/wx/doc/gen/variant.rb', line 211 def get_double; end |
#get_font ⇒ Wx::Font Also known as: font
Returns font value.
144 |
# File 'lib/wx/doc/variant.rb', line 144 def get_font; end |
#get_long ⇒ Integer Also known as: long
Returns the integer value.
216 |
# File 'lib/wx/doc/gen/variant.rb', line 216 def get_long; end |
#get_long_long ⇒ Integer Also known as: long_long
Returns the signed 64-bit integer value.
221 |
# File 'lib/wx/doc/gen/variant.rb', line 221 def get_long_long; end |
#get_name ⇒ Wx::String Also known as: name
Returns a constant reference to the variant name.
226 |
# File 'lib/wx/doc/gen/variant.rb', line 226 def get_name; end |
#get_object ⇒ Object Also known as: object
Returns a pointer to the internal variant data.
To take ownership of this data, you must call its Wx::VariantData#inc_ref method. When you stop using it, Wx::VariantData#dec_ref must be called as well.
201 |
# File 'lib/wx/doc/gen/variant.rb', line 201 def get_object; end |
#get_string ⇒ String Also known as: string
Gets the string value.
231 |
# File 'lib/wx/doc/gen/variant.rb', line 231 def get_string; end |
#get_type ⇒ String Also known as: type
Returns the value type as a string.
The built-in types are:
-
“bool”
-
“char”
-
“datetime”
-
“double”
-
“list”
-
“long”
-
“longlong”
-
“string”
-
“ulonglong”
-
“arrstring”
If the variant is null, the value type returned is the string “null” (not the empty string).
If the variant contains an arbitrary Ruby Object, the value type returned is the result of variant.get_object.class.name
.
253 |
# File 'lib/wx/doc/gen/variant.rb', line 253 def get_type; end |
#get_u_long_long ⇒ Integer Also known as: u_long_long
Returns the unsigned 64-bit integer value.
258 |
# File 'lib/wx/doc/gen/variant.rb', line 258 def get_u_long_long; end |
#insert(value) ⇒ void
This method returns an undefined value.
Inserts a value at the front of the list.
55 |
# File 'lib/wx/doc/gen/variant.rb', line 55 def insert(value) end |
#integer? ⇒ true, false
Checks if Variant contains an integer value (long|long long|unsigned long long).
113 |
# File 'lib/wx/doc/variant.rb', line 113 def integer?; end |
#is_null ⇒ Boolean Also known as: null?
Returns true if there is no data associated with this variant, false if there is data.
263 |
# File 'lib/wx/doc/gen/variant.rb', line 263 def is_null; end |
#is_type(type) ⇒ Boolean Also known as: type?
Returns true if type matches the type of the variant, false otherwise.
269 |
# File 'lib/wx/doc/gen/variant.rb', line 269 def is_type(type) end |
#list? ⇒ true, false
Checks if Variant contains a VariantList (array of Variant) value (not null).
132 |
# File 'lib/wx/doc/variant.rb', line 132 def list?; end |
#long? ⇒ true, false
Checks if Variant contains a long value (not null).
101 |
# File 'lib/wx/doc/variant.rb', line 101 def long?; end |
#long_long? ⇒ true, false
Checks if Variant contains a long long value (not null).
105 |
# File 'lib/wx/doc/variant.rb', line 105 def long_long?; end |
#make_null ⇒ void
This method returns an undefined value.
Makes the variant null by deleting the internal data.
274 |
# File 'lib/wx/doc/gen/variant.rb', line 274 def make_null; end |
#make_string ⇒ String
Makes a string representation of the variant value (for any type).
278 |
# File 'lib/wx/doc/gen/variant.rb', line 278 def make_string; end |
#member(value) ⇒ Boolean
Returns true if value matches an element in the list.
283 |
# File 'lib/wx/doc/gen/variant.rb', line 283 def member(value) end |
#null_list ⇒ void
This method returns an undefined value.
Makes an empty list.
This differs from a null variant which has no data; a null list is of type list, but the number of elements in the list is zero.
61 |
# File 'lib/wx/doc/gen/variant.rb', line 61 def null_list; end |
#numeric? ⇒ true, false
Checks if Variant contains an integer value (integer | double).
128 |
# File 'lib/wx/doc/variant.rb', line 128 def numeric?; end |
#object?(klass = Object) ⇒ true, false
Checks if Variant contains an unspecified Ruby object (not null or nil and not one of the other value types).
169 |
# File 'lib/wx/doc/variant.rb', line 169 def object?(klass=Object) end |
#string? ⇒ true, false
Checks if Variant contains a String value (not null).
93 |
# File 'lib/wx/doc/variant.rb', line 93 def string?; end |
#to_f ⇒ Float
Convert contained object to floating point value if possible. Raises TypeError exception if incompatible.
84 |
# File 'lib/wx/doc/variant.rb', line 84 def to_f; end |
#to_i ⇒ Integer
Convert contained object to integer value if possible. Raises TypeError exception if incompatible.
79 |
# File 'lib/wx/doc/variant.rb', line 79 def to_i; end |
#to_s ⇒ String
Convert contained object to string value if possible. Raises TypeError exception if incompatible.
89 |
# File 'lib/wx/doc/variant.rb', line 89 def to_s; end |
#u_long_long? ⇒ true, false
Checks if Variant contains an unsigned long long value (not null).
109 |
# File 'lib/wx/doc/variant.rb', line 109 def u_long_long?; end |
#unshare ⇒ Boolean
Makes sure that any data associated with this variant is not shared with other variants.
For this to work, Wx::VariantData#clone must be implemented for the data types you are working with. Wx::VariantData#clone is implemented for all the default data types.
289 |
# File 'lib/wx/doc/gen/variant.rb', line 289 def unshare; end |