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



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/alexa_modelmd.rb', line 30

def entries()

  r = super()

  r.map do |entry|

    def entry.intents()
      self.body().split(/(?=^## )/).map {|x| Intent.new(x)}
    end

    entry

  end

end

#to_modelbObject

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



49
50
51
# File 'lib/alexa_modelmd.rb', line 49

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

#to_xmlObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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
# File 'lib/alexa_modelmd.rb', line 53

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

            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

          end
        end 
      end #/entries

    end #/model
  end

  Rexle.new(a).xml pretty: true

end