diff options
| author | Randy Morgan <[email protected]> | 2012-07-10 20:03:51 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-07-10 20:03:51 +0900 |
| commit | 8f0e868940fe7fd56e2c43e2b1102ec1d3e58a0e (patch) | |
| tree | f1ca3985d454980073aef0aa387626da565946c6 /lib | |
| parent | cc4f75ce39528ed90c57208e83e319370408dd12 (diff) | |
| download | caxlsx-8f0e868940fe7fd56e2c43e2b1102ec1d3e58a0e.tar.gz caxlsx-8f0e868940fe7fd56e2c43e2b1102ec1d3e58a0e.zip | |
code updates for readability.
part of an ongoing effort to make the code more readable code.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx/content_type/content_type.rb | 1 | ||||
| -rw-r--r-- | lib/axlsx/content_type/default.rb | 30 | ||||
| -rw-r--r-- | lib/axlsx/doc_props/app.rb | 58 |
3 files changed, 48 insertions, 41 deletions
diff --git a/lib/axlsx/content_type/content_type.rb b/lib/axlsx/content_type/content_type.rb index 003991c7..6fa6f944 100644 --- a/lib/axlsx/content_type/content_type.rb +++ b/lib/axlsx/content_type/content_type.rb @@ -1,5 +1,6 @@ # encoding: UTF-8 module Axlsx + require 'axlsx/content_type/default.rb' require 'axlsx/content_type/override.rb' diff --git a/lib/axlsx/content_type/default.rb b/lib/axlsx/content_type/default.rb index 21e89217..8baafb77 100644 --- a/lib/axlsx/content_type/default.rb +++ b/lib/axlsx/content_type/default.rb @@ -1,8 +1,22 @@ # encoding: UTF-8 module Axlsx + # An default content part. These parts are automatically created by for you based on the content of your package. class Default + #Creates a new Default object + # @option options [String] extension + # @option options [String] content_type + # @raise [ArgumentError] An argument error is raised if both extension and content_type are not specified. + def initialize(options={}) + raise ArgumentError, INVALID_ARGUMENTS unless validate_options(options) + options.each do |name, value| + self.send("#{name}=", value) if self.respond_to? "#{name}=" + end + end + + INVALID_ARGUMENTS = "extension and content_type are required" + # # The extension of the content type. # @return [String] attr_reader :extension @@ -13,18 +27,6 @@ module Axlsx attr_reader :content_type alias :ContentType :content_type - #Creates a new Default object - # @option options [String] extension - # @option options [String] content_type - # @raise [ArgumentError] An argument error is raised if both extension and content_type are not specified. - def initialize(options={}) - raise ArgumentError, "extension and content_type are required" unless (options[:Extension] || options[:extension]) && (options[:content_type] || options[:ContentType]) - options.each do |o| - self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" - end - end - - # Sets the file extension for this content type. def extension=(v) Axlsx::validate_string v; @extension = v end alias :Extension= :extension= @@ -43,5 +45,9 @@ module Axlsx str << '/>' end + private + def validate_options(options) + (options[:Extension] || options[:extension]) && (options[:content_type] || options[:ContentType]) + end end end diff --git a/lib/axlsx/doc_props/app.rb b/lib/axlsx/doc_props/app.rb index 0d3968cd..52891e28 100644 --- a/lib/axlsx/doc_props/app.rb +++ b/lib/axlsx/doc_props/app.rb @@ -10,6 +10,35 @@ module Axlsx # DigSig (DigSigBlob) class App + # Creates an App object + # @option options [String] template + # @option options [String] manager + # @option options [Integer] pages + # @option options [Integer] words + # @option options [Integer] characters + # @option options [String] presentation_format + # @option options [Integer] lines + # @option options [Integer] paragraphs + # @option options [Integer] slides + # @option options [Integer] notes + # @option options [Integer] total_time + # @option options [Integer] hidden_slides + # @option options [Integer] m_m_clips + # @option options [Boolean] scale_crop + # @option options [Boolean] links_up_to_date + # @option options [Integer] characters_with_spaces + # @option options [Boolean] share_doc + # @option options [String] hyperlink_base + # @option options [String] hyperlinks_changed + # @option options [String] application + # @option options [String] app_version + # @option options [Integer] doc_security + def initialize(options={}) + options.each do |name, value| + self.send("#{name}=", value) if self.respond_to? "#{name}=" + end + end + # @return [String] The name of the document template. attr_reader :template alias :Template :template @@ -102,35 +131,6 @@ module Axlsx attr_reader :doc_security alias :DocSecurity :doc_security - # Creates an App object - # @option options [String] template - # @option options [String] manager - # @option options [Integer] pages - # @option options [Integer] words - # @option options [Integer] characters - # @option options [String] presentation_format - # @option options [Integer] lines - # @option options [Integer] paragraphs - # @option options [Integer] slides - # @option options [Integer] notes - # @option options [Integer] total_time - # @option options [Integer] hidden_slides - # @option options [Integer] m_m_clips - # @option options [Boolean] scale_crop - # @option options [Boolean] links_up_to_date - # @option options [Integer] characters_with_spaces - # @option options [Boolean] share_doc - # @option options [String] hyperlink_base - # @option options [String] hyperlinks_changed - # @option options [String] application - # @option options [String] app_version - # @option options [Integer] doc_security - def initialize(options={}) - options.each do |o| - self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" - end - end - # Sets the template property of your app.xml file def template=(v) Axlsx::validate_string v; @template = v; end alias :Template :template |
