Class: Array
- Defined in:
- lib/utilrb/array/to_s.rb,
lib/utilrb/enumerable/random_element.rb
Instance Method Summary collapse
-
#random_element ⇒ Object
Returns a random element of the array.
- #to_s ⇒ Object
-
#to_value_set ⇒ Object
Converts this array into a ValueSet object.
Instance Method Details
#random_element ⇒ Object
Returns a random element of the array
3 |
# File 'lib/utilrb/enumerable/random_element.rb', line 3 def random_element; self[rand(size)] end |
#to_s ⇒ Object
6 7 8 9 10 |
# File 'lib/utilrb/array/to_s.rb', line 6 def to_s EnumerableToString.to_s_helper(self, '[', ']') do |obj| obj.to_s end end |
#to_value_set ⇒ Object
Converts this array into a ValueSet object
355 356 357 358 359 360 361 362 363 364 365 |
# File 'ext/value_set.cc', line 355
static VALUE array_to_value_set(VALUE self)
{
VALUE vresult = rb_funcall2(cValueSet, id_new, 0, NULL);
ValueSet& result = get_wrapped_set(vresult);
long size = RARRAY_LEN(self);
for (int i = 0; i < size; ++i)
result.insert(rb_ary_entry(self, i));
return vresult;
}
|