Class: RLTK::CG::Value::AttrCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/rltk/cg/value.rb

Overview

This class is used to access a Value’s attributes.

Constant Summary collapse

@@add_method =
:add_attribute
@@del_method =
:remove_attribute

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ AttrCollection

Returns a new instance of AttrCollection.

Parameters:

  • value (Value)

    Value for which this is a proxy.



157
158
159
160
# File 'lib/rltk/cg/value.rb', line 157

def initialize(value)
	@attributes	= Array.new
	@value		= value
end

Instance Method Details

#add(attribute) ⇒ void Also known as: <<

This method returns an undefined value.

Add the given attribute to a value.

Parameters:

  • attribute (Symbol)

    Attribute to add.

See Also:



169
170
171
172
173
174
# File 'lib/rltk/cg/value.rb', line 169

def add(attribute)
	if not @attributes.include?(attribute)
		@attributes << attribute
		Bindings.send(@@add_method, @value, attribute)
	end
end

#include?(attribute) ⇒ Boolean

Test to see if an attribute has been set on a value.

Parameters:

  • attribute (Symbol)

    Attribute to check.

Returns:

  • (Boolean)

See Also:



184
185
186
# File 'lib/rltk/cg/value.rb', line 184

def include?(attribute)
	@attributes.include?(attribute)
end

#remove(attribute) ⇒ void Also known as: >>

This method returns an undefined value.

Remove the given attribute from a value.

Parameters:

  • attribute (Symbol)

    Attribute to remove.

See Also:



195
196
197
198
199
200
# File 'lib/rltk/cg/value.rb', line 195

def remove(attribute)
	if @attributes.include?(attribute)
		@attributes.delete(attribute)
		Bindings.send(@@del_method, @value, attribute)
	end
end

#to_sString

Returns Textual representation of the enabled attributes.

Returns:

  • (String)

    Textual representation of the enabled attributes.



204
205
206
# File 'lib/rltk/cg/value.rb', line 204

def to_s
	@attributes.to_s
end