Class: RLTK::CG::Value::AttrCollection
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.
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.
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.
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.
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_s ⇒ String
Returns Textual representation of the enabled attributes.
217 218 219 |
# File 'lib/rltk/cg/value.rb', line 217 def to_s @attributes.to_s end |