Sha256: 6a16ed89608278add042aeeb9c4ff5b81c276c997281e2a229b86c6d7f87263b

Contents?: true

Size: 849 Bytes

Versions: 3

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

module Goldendocx
  module Components
    class Text
      include Goldendocx::Element

      namespace :w
      tag :p

      embeds_one :property, class_name: 'Goldendocx::Components::Properties::Property', auto_build: true
      embeds_one :run, class_name: 'Goldendocx::Components::Properties::Run', auto_build: true

      def align=(align)
        property.align.align = align if align
      end

      def style=(style)
        property.style.style_id = style if style
      end

      def text=(text)
        run.build_text.value = text if text
      end

      def color=(color_hex)
        (run.property || run.build_property).build_color(hex: color_hex) if color_hex
      end

      def bold=(bold)
        (run.property || run.build_property).build_bold(enabled: bold) if bold
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
goldendocx-0.3.0 lib/goldendocx/components/text.rb
goldendocx-0.2.3 lib/goldendocx/components/text.rb
goldendocx-0.2.2 lib/goldendocx/components/text.rb