Module: Asciidoctor::Rfc::V2::Front

Included in:
Converter
Defined in:
lib/asciidoctor/rfc/v2/front.rb

Instance Method Summary collapse

Instance Method Details

#address(node, suffix, xml) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/asciidoctor/rfc/v2/front.rb', line 32

def address(node, suffix, xml)
  email = node.attr("email#{suffix}")
  facsimile = node.attr("fax#{suffix}")
  phone = node.attr("phone#{suffix}")
  street = node.attr("street#{suffix}")
  uri = node.attr("uri#{suffix}")

  # If there is no provided elements for address, don't show it
  return unless [email, facsimile, phone, street, uri].any?

  # https://tools.ietf.org/html/rfc7749#section-2.27
  # Note that at least one <street> element needs to be present;
  # however, formatters will handle empty values just fine.
  street = street ? street.split("\\ ") : [""]

  xml.address do |xml_address|
    xml_address.postal do |xml_postal|
      city = node.attr("city#{suffix}")
      code = node.attr("code#{suffix}")
      country = node.attr("country#{suffix}")
      region = node.attr("region#{suffix}")

      street.each { |st| xml_postal.street { |s| s << st } }
      xml_postal.city { |c| c << city } unless city.nil?
      xml_postal.region { |r| r << region } unless region.nil?
      xml_postal.code { |c| c << code } unless code.nil?
      xml_postal.country { |c| c << country } unless country.nil?
    end

    xml_address.phone { |p| p << phone } unless phone.nil?
    xml_address.facsimile { |f| f << facsimile } unless facsimile.nil?
    xml_address.email { |e| e << email } unless email.nil?
    xml_address.uri { |u| u << uri } unless uri.nil?
  end
end

#front(node, xml) ⇒ Object

Syntax:

= Title
Author
:METADATA


8
9
10
11
12
13
14
15
16
17
# File 'lib/asciidoctor/rfc/v2/front.rb', line 8

def front(node, xml)
  xml.front do |xml_front|
    title node, xml_front
    author node, xml_front
    date node, xml_front
    area node, xml_front
    workgroup node, xml_front
    keyword node, xml_front
  end
end

#organization(node, suffix, xml) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/asciidoctor/rfc/v2/front.rb', line 19

def organization(node, suffix, xml)
  organization = node.attr("organization#{suffix}")
  organization_abbrev = node.attr("organization_abbrev#{suffix}")
  organization_attributes = {
    abbrev: organization_abbrev,
  }
  unless organization.nil?
    xml.organization **attr_code(organization_attributes) do |org|
      org << organization
    end
  end
end