Class: BasicBlock::Stem

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

Constant Summary collapse

TYPES =
%w[MathML AsciiMath].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, content: []) ⇒ Stem

Returns a new instance of Stem.

Parameters:

  • type (String)
  • content (Array<#to_xml>) (defaults to: [])

    any element



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

def initialize(type:, content: [])
  unless TYPES.include? type
    Util.warn "Invalud type: `#{type}`\nAllowed types are: `#{TYPES.join '`, `'}`"
  end
  @type = type
  @content = content
end

Instance Attribute Details

#typeString (readonly)

Returns:

  • (String)


6
7
8
# File 'lib/relaton_iec/basic_block/stem.rb', line 6

def type
  @type
end

Instance Method Details

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


23
24
25
26
27
# File 'lib/relaton_iec/basic_block/stem.rb', line 23

def to_xml(builder)
  builder.stem(type) do |b|
    content.each { |c| c.to_xml b }
  end
end