Class | RuCodeGen::ValueIncapsulator |
In: |
lib/rucodegen/value_incapsulator.rb
|
Parent: | Object |
Класс, который содержит описания C++ класса для шаблона ValueIncapsulator.
ATTR_DEFAULT_VALUE | = | :default | Ключ, который определяет начальное значение атрибута. | |
GETTER_RETURNS_VALUE | = | :getter_returns_value | Ключ, которые заставляет getter возвращать значение атрибута, а не ссылку на атрибут. |
class_name | [R] | Имя класса в C++. |
Метаметоды, которые упростят создание getter-ов и setter-ов для атрибутов ValueIncapsulator.
# File lib/rucodegen/value_incapsulator.rb, line 105 def self.getter_setter_for( a_attribute ) class_eval %Q{ def get_#{a_attribute} @#{a_attribute} end def #{a_attribute}( a_value ) @#{a_attribute} = a_value end } end
Конструктор.
# File lib/rucodegen/value_incapsulator.rb, line 122 def initialize( a_class_name ) @class_name = a_class_name @attr_prefix = "" @attr_suffix = "" @getter_prefix = "" @setter_prefix = "" @attributes = [] @decl_file = nil @impl_file = nil end
Добавить еще один атрибут.
# File lib/rucodegen/value_incapsulator.rb, line 150 def attr( a_name, a_type, a_props = {} ) a = ClassAttribute.new( a_name, a_type ) a.default = a_props[ ATTR_DEFAULT_VALUE ] if a_props.has_key? ATTR_DEFAULT_VALUE a.getter_returns_value if a_props.has_key?( GETTER_RETURNS_VALUE ) and true == a_props[ GETTER_RETURNS_VALUE ] @attributes << a end