Class: Sketchup::Set Deprecated

Inherits:
Object
  • Object
show all
Defined in:
lib/sketchup-api-stubs/stubs/Sketchup/Set.rb

Overview

Deprecated.

In SketchUp 2014 this class was changed from Set to Sketchup::Set in order to avoid conflict with the Ruby Standard Library. The Sketchup::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 Sketchup::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 Method Summary collapse

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



56
57
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Set.rb', line 56

def clear
end

#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:

Returns:

  • (Boolean)

See Also:

Version:

  • SketchUp 6.0



75
76
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Set.rb', line 75

def contains?(entity)
end

#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



92
93
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Set.rb', line 92

def delete(object)
end

#each {|item| ... } ⇒ Object

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



107
108
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Set.rb', line 107

def each
end

#empty?Boolean

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



123
124
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Set.rb', line 123

def empty?
end

#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:

Returns:

  • (Boolean)

See Also:

Version:

  • SketchUp 6.0



143
144
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Set.rb', line 143

def include?(entity)
end

#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



160
161
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Set.rb', line 160

def insert(object)
end

#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

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 6.0



177
178
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Set.rb', line 177

def length
end

#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

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 6.0



194
195
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Set.rb', line 194

def size
end

#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
UI.messagebox my_array

Returns:

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

Version:

  • SketchUp 6.0



209
210
# File 'lib/sketchup-api-stubs/stubs/Sketchup/Set.rb', line 209

def to_a
end