Class: BasicBlock::TextElement

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_iec/basic_block/text_element.rb

Constant Summary collapse

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

Instance Method Summary collapse

Constructor Details

#initialize(tag:, content:) ⇒ TextElement

Returns a new instance of TextElement.

Parameters:



11
12
13
14
15
16
17
18
# File 'lib/relaton_iec/basic_block/text_element.rb', line 11

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

Instance Method Details

#to_xml(builder) ⇒ Object

Parameters:

  • (Nokogiri::XML::Builder)


21
22
23
24
25
# File 'lib/relaton_iec/basic_block/text_element.rb', line 21

def to_xml(builder)
  builder.send @tag do |b|
    @content.each { |c| c.is_a?(String) ? c : c.to_xml(b) }
  end
end