Module: Axlsx::Accessors::ClassMethods
- Defined in:
- lib/axlsx/util/accessors.rb
Overview
Defines the class level xxx_attr_accessor methods
Constant Summary collapse
- SETTER =
Template for defining validated write accessors
"def %s=(value) Axlsx::%s(value); @%s = value; end".freeze
Instance Method Summary collapse
-
#boolean_attr_accessor(*symbols) ⇒ Object
Creates on or more boolean validated attr_accessors names of the attributes you will add to your class.
-
#float_attr_accessor(*symbols) ⇒ Object
Creates one or more float (double?) attr_accessors names of the attributes you will add to your class.
-
#string_attr_accessor(*symbols) ⇒ Object
Creates one or more string validated attr_accessors names of the attributes you will add to your class.
-
#unsigned_int_attr_accessor(*symbols) ⇒ Object
Creates one or more usigned integer attr_accessors names of the attributes you will add to your class.
-
#validated_attr_accessor(symbols, validator) ⇒ Object
Creates the reader and writer access methods validating assignation.
Instance Method Details
#boolean_attr_accessor(*symbols) ⇒ Object
Creates on or more boolean validated attr_accessors names of the attributes you will add to your class.
41 42 43 |
# File 'lib/axlsx/util/accessors.rb', line 41 def boolean_attr_accessor(*symbols) validated_attr_accessor(symbols, :validate_boolean) end |
#float_attr_accessor(*symbols) ⇒ Object
Creates one or more float (double?) attr_accessors names of the attributes you will add to your class
34 35 36 |
# File 'lib/axlsx/util/accessors.rb', line 34 def float_attr_accessor(*symbols) validated_attr_accessor(symbols, :validate_float) end |
#string_attr_accessor(*symbols) ⇒ Object
Creates one or more string validated attr_accessors names of the attributes you will add to your class.
20 21 22 |
# File 'lib/axlsx/util/accessors.rb', line 20 def string_attr_accessor(*symbols) validated_attr_accessor(symbols, :validate_string) end |
#unsigned_int_attr_accessor(*symbols) ⇒ Object
Creates one or more usigned integer attr_accessors names of the attributes you will add to your class
27 28 29 |
# File 'lib/axlsx/util/accessors.rb', line 27 def unsigned_int_attr_accessor(*symbols) validated_attr_accessor(symbols, :validate_unsigned_int) end |
#validated_attr_accessor(symbols, validator) ⇒ Object
Creates the reader and writer access methods validating assignation.
53 54 55 56 57 58 59 |
# File 'lib/axlsx/util/accessors.rb', line 53 def validated_attr_accessor(symbols, validator) symbols.each do |symbol| attr_reader symbol module_eval(SETTER % [symbol, validator, symbol], __FILE__, __LINE__) end end |