Sha256: 9263d6b6fdf771c1f789920d931c9ec1333ab0b42c37448d8deb644d4ec87b8f

Contents?: true

Size: 1.46 KB

Versions: 18

Compression:

Stored size: 1.46 KB

Contents

module BasicBlock
  class Image
    #
    # @param [String] id
    # @param [String] src
    # @param [String] mimetype
    # @param [Hash] args
    # @option args [String] :filename
    #
    def initialize(id:, src:, mimetype:, **args) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
      @id = id
      @src = src
      @mimetype = mimetype
      @filename = args[:filename]
      if args[:width] && !args[:width].is_a?(Integer) && args[:width] != "auto"
        warn "[basic-block] WARNING: invalid image width attribute \"#{args[:width]}"
        warn "[basic-block] image width should be integer or \"auto\""
      end
      if args[:height] && !args[:height].is_a?(Integer) && args[:height] != "auto"
        warn "[basic-block] WARNING: invalid image height attribute \"#{args[:height]}"
        warn "[basic-block] image height should be integer or \"auto\""
      end
      @width = args[:width]
      @height = args[:height]
      @alt = args[:alt]
      @title = args[:title]
      @longdesc = args[:longdesc]
    end

    # @param [Nokogiri::XML::Builder]
    def to_xml(builder) # rubocop:disable Metrics/CyclomaticComplexity
      img = builder.image id: @id, src: @src, mimetype: @mimetype
      img[:filename] = @filename if @filename
      img[:width] = @width if @width
      img[:height] = @height if @height
      img[:alt] = @alt if @alt
      img[:title] = @title if @title
      img[:longdesc] = @longdesc if @longdesc
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
relaton-iec-1.16.1 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.16.0 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.14.4 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.14.3 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.14.2 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.14.1 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.14.0 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.13.0 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.12.0 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.11.4 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.11.3 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.11.2 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.11.1 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.11.0 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.10.1 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.10.0 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.9.0 lib/relaton_iec/basic_block/image.rb
relaton-iec-1.8.0 lib/relaton_iec/basic_block/image.rb