Class: RLTK::CG::Value::AttrCollection
- Inherits:
-
Object
- Object
- RLTK::CG::Value::AttrCollection
- 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
-
#add(attribute) ⇒ void
(also: #<<)
Add the given attribute to a value.
-
#include?(attribute) ⇒ Boolean
Test to see if an attribute has been set on a value.
-
#initialize(value) ⇒ AttrCollection
constructor
A new instance of AttrCollection.
-
#remove(attribute) ⇒ void
(also: #>>)
Remove the given attribute from a value.
-
#to_s ⇒ String
Textual representation of the enabled attributes.
Constructor Details
#initialize(value) ⇒ AttrCollection
Returns a new instance of AttrCollection.
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.
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.
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.
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_s ⇒ String
Returns Textual representation of the enabled attributes.
204 205 206 |
# File 'lib/rltk/cg/value.rb', line 204 def to_s @attributes.to_s end |