Class: AlexaModelMd

Inherits:
WikiMd
  • Object
show all
Defined in:
lib/alexa_modelmd.rb

Defined Under Namespace

Classes: Intent

Instance Method Summary collapse

Instance Method Details

#entriesObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/alexa_modelmd.rb', line 34

def entries()

  r = super()

  r.map do |entry|

    def entry.intents()
      puts 'entries | x: ' + x.inspect if @debug
      self.body().split(/(?=^## )/).map {|x| Intent.new(x, debug: @debug)}
    end

    entry

  end

end

#to_mdObject

Transforms the document into an Alexa_modelmd formatted document



53
54
55
# File 'lib/alexa_modelmd.rb', line 53

def to_md
  Rexslt.new(md_xslt(), to_xml(), debug: @debug).to_s
end

#to_modelbObject Also known as: to_txt

This generates a plain text file representing the Alexa Model to be built using the alexa_modelbuilder gem



60
61
62
# File 'lib/alexa_modelmd.rb', line 60

def to_modelb
  Rexslt.new(modelbuilder_xslt(), to_xml()).to_s    
end

#to_rsfObject



66
67
68
# File 'lib/alexa_modelmd.rb', line 66

def to_rsf
  Rexslt.new(rsf_xslt(), to_xml(), debug: @debug).to_s
end

#to_xmlObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/alexa_modelmd.rb', line 70

def to_xml()

  a = RexleBuilder.build do |xml|

    xml.model do

      xml.summary do
        xml.title @dxsx.dx.title
        xml.invocation @dxsx.dx.invocation
        xml.endpoint @dxsx.dx.endpoint
      end

      xml.entries do 
        entries.each do |entry|

          xml.entry do
            xml.topic entry.heading.strip

            xml.intents do
              entry.intents.each do |intent|

                xml.intent do

                  xml.name intent.name

                  xml.utterances do
                    intent.utterances.each do |utterance|
                      xml.utterance utterance
                    end
                  end

                  xml.code do              
                    xml.cdata! intent.code
                  end
                end #/intent
              end
            end #/intents

            xml.tags do
              entry.tags.each do |tag|
                xml.tag tag
              end
            end
            
          end
        end 
      end #/entries

    end #/model
  end

  Rexle.new(a).xml pretty: true

end