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.



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

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:



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

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:



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

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:



208
209
210
211
212
213
# File 'lib/rltk/cg/value.rb', line 208

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.



217
218
219
# File 'lib/rltk/cg/value.rb', line 217

def to_s
	@attributes.to_s
end