Sha256: 181ab3930698878ae9b3372c2ac8a43fdbc9284216408708e49df44aef4d8c45

Contents?: true

Size: 738 Bytes

Versions: 24

Compression:

Stored size: 738 Bytes

Contents

module BasicBlock
  class TextElement
    TAGS = %w[em strong sub sup tt underline strike smallcap br hr keyword rp
              rt ruby pagebreak bookmark].freeze

    #
    # @param [String] tag
    # @param [Array<String, BasicBlock::TextElement, BasicBlock::Stem>,
    #   String] content
    #
    def initialize(tag:, content:)
      unless TAGS.include? tag
        warn "[basic-block] WARNING: invalid tag \"#{tag}\""
        warn "[basic-block] allowed tags are: #{TAGS.join ', '}"
      end
      @tag = tag
      @content = content
    end

    # @param [Nokogiri::XML::Builder]
    def to_xml(builder)
      builder.send @tag do |b|
        @content.each { |c| c.is_a?(String) ? c : c.to_xml(b) }
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
relaton-iec-1.18.1 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.18.0 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.17.0 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.16.4 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.16.3 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.16.2 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.16.1 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.16.0 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.14.4 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.14.3 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.14.2 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.14.1 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.14.0 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.13.0 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.12.0 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.11.4 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.11.3 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.11.2 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.11.1 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.11.0 lib/relaton_iec/basic_block/text_element.rb