Class: Sketchup::OptionsProvider

Inherits:
Object
  • Object
show all
Includes:
Enumerable

Overview

An OptionsProvider class provides various kinds of options on a Model. You get an OptionsProvider from the OptionsManager. The options are given as name/value pairs.

Version:

  • SketchUp 6.0

Instance Method Summary # collapse

Instance Method Details

#[](index) ⇒ Object #[](name) ⇒ Object

The [] method is used to get a value by name or index of the key.

Examples:

model = Sketchup.active_model
manager = model.options
provider = manager[0]
# Retrieves the provider at index 1
option = provider[1]

Overloads:

  • #[](index) ⇒ Object

    Returns value - the value if successful

    Parameters:

    • index

      The index for a specific key.

    Returns:

    • value - the value if successful

  • #[](name) ⇒ Object

    Returns value - the value if successful

    Parameters:

    • name

      The name of the specific key.

    Returns:

    • value - the value if successful

Version:

  • SketchUp 6.0

#[]=(key, value) ⇒ Object

The []= method is used to set the value of a specific key.

Creates a new attribute for the given key if needed.

Examples:

option = provider[1]=10

Returns value - the value that was set if successful, or false if unsuccessful.

Parameters:

  • key

    The valid key.

  • value

    The value to be set.

Returns:

  • value - the value that was set if successful, or false if unsuccessful.

Version:

  • SketchUp 6.0

#add_observer(observer) ⇒ Object

The add_observer method is used to add an observer to the current object.

Examples:

status = object.add_observer observer

Returns true if successful, false if unsuccessful.

Parameters:

  • observer

    An observer.

Returns:

  • true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0

#countInteger

Note:

Since SketchUp 2014 the count method is inherited from Ruby's Enumable mix-in module. Prior to that the #count method is an alias for #length.

Examples:

optionsprovider = Sketchup.active_model.options['UnitsOptions']
number = optionsprovider.count

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 6.0

#each {|key, value| ... } ⇒ nil

The #each method is used to iterate through all of the options.

Examples:

model = Sketchup.active_model.options
provider = model.options['UnitsOptions']
provider.each { |key, value| puts "#{key} = #{value}" }

Yields:

  • (key, value)

Yield Parameters:

Returns:

  • (nil)

See Also:

Version:

  • SketchUp 6.0

#each_key {|key| ... } ⇒ nil

The #each_key method is used to iterate through all of the attribute keys.

Examples:

provider.each_key { |key| UI.messagebox key }

Yields:

  • (key)

Yield Parameters:

Returns:

  • (nil)

Version:

  • SketchUp 6.0

#each_pair {|key, value| ... } ⇒ nil

The #each method is used to iterate through all of the options.

Examples:

model = Sketchup.active_model.options
provider = model.options['UnitsOptions']
provider.each { |key, value| puts "#{key} = #{value}" }

Yields:

  • (key, value)

Yield Parameters:

Returns:

  • (nil)

See Also:

Version:

  • SketchUp 6.0

#each_value {|value| ... } ⇒ Object

The each_value method is used to iterate through all of the attribute values.

Throws an exception if there are no keys.

Examples:

provider.each_value { |value| UI.messagebox value }

Yields:

  • (value)

    A variable that will hold each value as they are found.

Returns:

  • nil

Version:

  • SketchUp 6.0

#has_key?(name) ⇒ Boolean

The #has_key? method is an alias for #key?.

Examples:

model = Sketchup.active_model.options
provider = model.options['UnitsOptions']
p provider.has_key?("LengthFormat")

Parameters:

  • name (String)

    The name of the key you are looking for.

Returns:

  • (Boolean)

Returns:

  • (Boolean)

See Also:

Version:

  • SketchUp 6.0

#key?(name) ⇒ Boolean

The #key? method is used to determine if the options provider has a specific key.

Examples:

model = Sketchup.active_model.options
provider = model.options['UnitsOptions']
p provider.key?("LengthFormat")

Parameters:

  • name (String)

    The name of the key you are looking for.

Returns:

  • (Boolean)

Returns:

  • (Boolean)

See Also:

Version:

  • SketchUp 6.0

#keysObject

The keys method is used to retrieve an array with all of the attribute keys.

Examples:

keys = provider.keys
key = keys[0]
if (key)
  UI.messagebox key
else
  UI.messagebox "Failure"
end

Returns:

  • keys - an array of keys within the options provider if successful

Version:

  • SketchUp 6.0

#lengthInteger

The #length method is an alias of #size.

Examples:

optionsprovider = Sketchup.active_model.options['UnitsOptions']
number = optionsprovider.length

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 2014

#nameObject

The name method is used to retrieve the name of an options provider.

Examples:


name = provider.name

Returns:

  • name - the name of the options provider if successful

Version:

  • SketchUp 6.0

#remove_observer(observer) ⇒ Object

The remove_observer method is used to remove an observer from the current object.

Examples:

status = object.remove_observer observer

Returns true if successful, false if unsuccessful.

Parameters:

  • observer

    An observer.

Returns:

  • true if successful, false if unsuccessful.

Version:

  • SketchUp 6.0

#sizeInteger

The #size method is used to retrieve the size (number of elements) of an options provider.

Examples:

optionsprovider = Sketchup.active_model.options['UnitsOptions']
number = optionsprovider.size

Returns:

  • (Integer)

See Also:

Version:

  • SketchUp 6.0