123456789_123456789_123456789_123456789_123456789_

Class: Sketchup::Set Deprecated

Relationships
Inherits: Object

Overview

Deprecated.

In SketchUp 2014 this class was changed from Set to Set in order to avoid conflict with the Ruby Standard Library. The Set class is deprecated and new extensions should make use of Ruby’s Set class unless they need backward compatibility.

The set class represents a collection of unique objects. This class is useful for keeping track of a group of related entities, kind of like a selection set that stays around for as long as you need it to.

To make a set of your own, create an empty one using Set.new, and then add items to it.

Examples:

set = Sketchup::Set.new
set.insert(1)
set.insert(2)

Compatibility Shim

module Example

  # Shim for the Set class which was moved in SketchUp 2014
  if defined?(Sketchup::Set)
    # Warning! Do NOT do this in the global namespace!
    Set = Sketchup::Set
  end

  def self.test_set_shim
    set = Set.new
    set.insert('Hello')
    set.insert('World')
    puts set.to_a
  end

end

Version:

  • SketchUp 6.0

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#empty?Boolean (readonly)

The empty? method is used to determine whether the set is empty.

Examples:

set = Sketchup::Set.new
set.insert(1)
set.insert(2)
set.insert(3)
puts set.empty?

Returns:

  • (Boolean)

    status - true if the set is empty, false if it is not empty.

Version:

  • SketchUp 6.0

Instance Method Details

#clearObject

The clear method is used to clear all objects out of the set.

Examples:

set = Sketchup::Set.new
set.insert(1)
set.insert(2)
set.insert(3)
set.clear

Returns:

  • set - an empty Set object

Version:

  • SketchUp 6.0

#contains?(entity) ⇒ Boolean

The #contains? method is an alias for #include?.

Examples:

set = Sketchup::Set.new
set.insert(1)
set.insert(2)
set.insert(3)
p set.contains?(2)

Parameters:

See Also:

Version:

  • SketchUp 6.0

#delete(object) ⇒ Object

The delete object is used to delete or remove an object from the set.

Examples:

set = Sketchup::Set.new
set.insert(1)
set.insert(2)
set.delete(1)

Parameters:

  • object

    The object to be deleted.

Returns:

  • object - the object that was deleted.

Version:

  • SketchUp 6.0

#each {|item| ... }

The each method is used to iterate through all of the objects in the set.

Examples:

set = Sketchup::Set.new
set.insert(1)
set.insert(2)
set.insert(3)
set.each { | item | puts item }

Yields:

  • (item)

Version:

  • SketchUp 6.0

#include?(entity) ⇒ Boolean

The #include? method is used to determine if the set includes a particular object.

Examples:

set = Sketchup::Set.new
set.insert(1)
set.insert(2)
set.insert(3)
p set.include?(2)

Parameters:

See Also:

Version:

  • SketchUp 6.0

#insert(object) ⇒ Object

The insert method is used to insert an object into the set.

Examples:

set = Sketchup::Set.new
set.insert(1)
set.insert(2)
set.insert(3)

Parameters:

  • object

    The object to be inserted into the set.

Returns:

  • size - the number of objects in the set

Version:

  • SketchUp 6.0

#lengthInteger

The #length method is an alias for #size.

Examples:

set = Sketchup::Set.new
set.insert(1)
set.insert(2)
set.insert(3)
puts set.length

See Also:

Version:

  • SketchUp 6.0

#sizeInteger

The #size method is used to determine the number of objects in the set.

Examples:

set = Sketchup::Set.new
set.insert(1)
set.insert(2)
set.insert(3)
puts set.size

See Also:

Version:

  • SketchUp 6.0

#to_aObject

The to_a method is used to get an ::Array of the entities in your Set.

Examples:

set = Sketchup::Set.new
set.insert('Hello')
set.insert('World')
my_array = set.to_a

Returns:

  • array - The Array of the entities in the Set.

Version:

  • SketchUp 6.0