class EdifactConverter::Configuration::XMLRule

Constants

ATTRIBUTES

Public Class Methods

new(options) click to toggle source
# File lib/edifact_converter/configuration/xml_rule.rb, line 22
def initialize(options)
  options.each do |name, value|
    if ATTRIBUTES.include? name.to_sym
      send "#{name}=", value
    end
  end
end

Public Instance Methods

from_xml() click to toggle source
# File lib/edifact_converter/configuration/xml_rule.rb, line 37
def from_xml
  @from_xml ||= begin
    xmldoc = load_doc_from_urls from_xml_urls
    Nokogiri::XSLT::Stylesheet.parse_stylesheet_doc xmldoc
  end
end
schema() click to toggle source
# File lib/edifact_converter/configuration/xml_rule.rb, line 30
def schema
  @schema ||= begin
    xmldoc = load_doc_from_urls schema_urls
    Nokogiri::XML::Schema.from_document xmldoc
  end
end
to_html() click to toggle source
# File lib/edifact_converter/configuration/xml_rule.rb, line 51
def to_html
  @to_html ||= begin
    xmldoc = load_doc_from_urls to_html_urls
    Nokogiri::XSLT::Stylesheet.parse_stylesheet_doc xmldoc
  end
end
to_xml() click to toggle source
# File lib/edifact_converter/configuration/xml_rule.rb, line 44
def to_xml
  @to_xml ||= begin
    xmldoc = load_doc_from_urls to_xml_urls
    Nokogiri::XSLT::Stylesheet.parse_stylesheet_doc xmldoc
  end
end

Private Instance Methods

load_doc_from_urls(urls) click to toggle source
# File lib/edifact_converter/configuration/xml_rule.rb, line 60
def load_doc_from_urls(urls)
  urls.each do |url|
    begin
      xmldoc = Nokogiri::XML(open(url), url)
    rescue StandardError => error
      $stderr.puts error
      next
    end
    break xmldoc
  end
end