diff options
| author | Jurriaan Pruis <[email protected]> | 2014-01-15 23:44:02 +0100 |
|---|---|---|
| committer | Jurriaan Pruis <[email protected]> | 2014-02-26 20:09:21 +0100 |
| commit | be8e00332c73439cf17083173ea74f1505100df9 (patch) | |
| tree | 383ec2e23fc0a14aa5ad90e139648a79814eeded /lib/axlsx/util/serialized_attributes.rb | |
| parent | a271a7d0f26ecb26d01aad00e094744d6fe8b0d2 (diff) | |
| download | caxlsx-be8e00332c73439cf17083173ea74f1505100df9.tar.gz caxlsx-be8e00332c73439cf17083173ea74f1505100df9.zip | |
Huge refactoring
Do not create huge strings
Let Row inherit from SimpleTypedList
Optimized sanitizing
Optimized validation
And more..
Diffstat (limited to 'lib/axlsx/util/serialized_attributes.rb')
| -rw-r--r-- | lib/axlsx/util/serialized_attributes.rb | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/axlsx/util/serialized_attributes.rb b/lib/axlsx/util/serialized_attributes.rb index 2a651ede..0b71c70b 100644 --- a/lib/axlsx/util/serialized_attributes.rb +++ b/lib/axlsx/util/serialized_attributes.rb @@ -18,9 +18,7 @@ module Axlsx end # a reader for those attributes - def xml_attributes - @xml_attributes - end + attr_reader :xml_attributes # This helper registers the attributes that will be formatted as elements. def serializable_element_attributes(*symbols) @@ -28,8 +26,20 @@ module Axlsx end # attr reader for element attributes - def xml_element_attributes - @xml_element_attributes + attr_reader :xml_element_attributes + end + + # creates a XML tag with serialized attributes + # @see SerializedAttributes#serialized_attributes + def serialized_tag(tagname, str, additional_attributes = {}, &block) + str << "<#{tagname} " + serialized_attributes(str, additional_attributes) + if block_given? + str << '>' + yield + str << "</#{tagname}>" + else + str << '/>' end end |
