Sha256: e36d41f66b8b81bef8aa4aac035319c26294b8bd688f3222a1b43843e274905e

Contents?: true

Size: 530 Bytes

Versions: 1

Compression:

Stored size: 530 Bytes

Contents

require 'tempfile'

module Schematron
  module Utils
    def create_temp_file(content, &block)
      temp_file = Tempfile.new('temp_file')
      temp_file.write(content)
      temp_file.rewind

      begin
        block.call(temp_file)
      ensure
        temp_file.close
        temp_file.unlink
      end
    end

    def get_attribute_value(element, xpath)
      result = ''
      attributes = element.xpath(xpath)

      if attributes.size > 0
        result = attributes.first.value
      end

      result
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
schematron-wrapper-1.0.0 lib/schematron/utils.rb