Sha256: 41620c53aabbab4700619c678eba4a5bbb9c0f59ed6e801489888cbc1827bd36

Contents?: true

Size: 1.2 KB

Versions: 10

Compression:

Stored size: 1.2 KB

Contents

module OpenXml
  module Docx
    module Elements
      class Ruby < Container
        attr_reader :base, :ruby

        value_property :alignment, as: :phonetic_guide_alignment
        value_property :base_font_size, as: :phonetic_guide_base_font_size
        value_property :font_size, as: :phonetic_guide_font_size
        value_property :font_size_raise, as: :phonetic_guide_font_size_raise
        value_property :language, as: :phonetic_guide_language

        def base=(other)
          raise ArgumentError unless other.is_a?(OpenXml::Docx::Elements::Run)
          @base = other
        end

        def ruby=(other)
          raise ArgumentError unless other.is_a?(OpenXml::Docx::Elements::Run)
          @ruby = other
        end

        def to_xml(xml)
          xml[namespace].public_send(tag, xml_attributes) {
            property_xml(xml)
            ruby_text_xml(xml)
            base_text_xml(xml)
          }
        end

      private

        def ruby_text_xml(xml)
          xml["w"].rt {
            ruby.to_xml(xml) if ruby
          }
        end

        def base_text_xml(xml)
          xml["w"].rubyBase {
            base.to_xml(xml) if base
          }
        end

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
openxml-docx-0.10.6 lib/openxml/docx/elements/ruby.rb
openxml-docx-0.10.5 lib/openxml/docx/elements/ruby.rb
openxml-docx-0.10.4 lib/openxml/docx/elements/ruby.rb
openxml-docx-0.10.3 lib/openxml/docx/elements/ruby.rb
openxml-docx-0.10.2 lib/openxml/docx/elements/ruby.rb
openxml-docx-0.10.1 lib/openxml/docx/elements/ruby.rb
openxml-docx-0.10.0 lib/openxml/docx/elements/ruby.rb
openxml-docx-0.9.0 lib/openxml/docx/elements/ruby.rb
openxml-docx-0.8.0 lib/openxml/docx/elements/ruby.rb
openxml-docx-0.8.0.beta1 lib/openxml/docx/elements/ruby.rb