Class: EdifactConverter::Configuration::XMLRule

Inherits:
Object
  • Object
show all
Defined in:
lib/edifact_converter/configuration/xml_rule.rb

Constant Summary collapse

ATTRIBUTES =
[
  :namespace,
  :versions,
  :schema,
  :schema_urls,
  :from_xml,
  :from_xml_urls,
  :to_xml,
  :to_xml_urls,
  :to_html,
  :to_html_urls
]

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ XMLRule

Returns a new instance of XMLRule.



22
23
24
25
26
27
28
# 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

Instance Method Details

#from_xmlObject



37
38
39
40
41
42
# 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

#schemaObject



30
31
32
33
34
35
# 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_htmlObject



51
52
53
54
55
56
# 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_xmlObject



44
45
46
47
48
49
# 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