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.10.1 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.10.0 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.9.0 lib/relaton_iec/basic_block/text_element.rb
relaton-iec-1.8.0 lib/relaton_iec/basic_block/text_element.rb