Class: AlexaModelMd
- Inherits:
-
WikiMd
- Object
- WikiMd
- AlexaModelMd
- Defined in:
- lib/alexa_modelmd.rb
Defined Under Namespace
Classes: Intent
Instance Method Summary collapse
- #endpoint ⇒ Object
- #endpoint=(s) ⇒ Object
- #entries ⇒ Object
-
#initialize(wiki = nil, keywords = {}) ⇒ AlexaModelMd
constructor
A new instance of AlexaModelMd.
- #invocation ⇒ Object
- #invocation=(s) ⇒ Object
-
#to_md ⇒ Object
Transforms the document into an Alexa_modelmd formatted document.
-
#to_modelb ⇒ Object
(also: #to_txt)
This generates a plain text file representing the Alexa Model to be built using the alexa_modelbuilder gem.
- #to_rsf ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(wiki = nil, keywords = {}) ⇒ AlexaModelMd
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 67 68 69 |
# File 'lib/alexa_modelmd.rb', line 35 def initialize(wiki=nil, keywords={}) wcis = keywords.delete :whatcanisay puts 'wcis: ' + wcis.inspect if @debug super(wiki, keywords) if wcis then found = self.find 'What can I say' if not found then s=<<EOF # What can I say ## WhatCanISay * what can I say * give me some examples ` #rsc.alexamodelmd.sample_utterances '#{self.title}' "Not yet enabled." ` + help whatcanisay EOF self.create_section s end end end |
Instance Method Details
#endpoint ⇒ Object
88 |
# File 'lib/alexa_modelmd.rb', line 88 def endpoint() @dxsx.dx.endpoint end |
#endpoint=(s) ⇒ Object
89 |
# File 'lib/alexa_modelmd.rb', line 89 def endpoint=(s) @dxsx.dx.endpoint = s end |
#entries ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/alexa_modelmd.rb', line 71 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 |
#invocation ⇒ Object
90 |
# File 'lib/alexa_modelmd.rb', line 90 def invocation() @dxsx.dx.invocation end |
#invocation=(s) ⇒ Object
91 |
# File 'lib/alexa_modelmd.rb', line 91 def invocation=(s) @dxsx.dx.invocation = s end |
#to_md ⇒ Object
Transforms the document into an Alexa_modelmd formatted document
95 96 97 |
# File 'lib/alexa_modelmd.rb', line 95 def to_md Rexslt.new(md_xslt(), to_xml(), debug: @debug).to_s end |
#to_modelb ⇒ Object Also known as: to_txt
This generates a plain text file representing the Alexa Model to be built using the alexa_modelbuilder gem
102 103 104 |
# File 'lib/alexa_modelmd.rb', line 102 def to_modelb Rexslt.new(modelbuilder_xslt(), to_xml()).to_s end |
#to_rsf ⇒ Object
108 109 110 |
# File 'lib/alexa_modelmd.rb', line 108 def to_rsf Rexslt.new(rsf_xslt(), to_xml(), debug: @debug).to_s end |
#to_xml ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/alexa_modelmd.rb', line 112 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. do entry..each do |tag| xml.tag tag end end end end end #/entries end #/model end Rexle.new(a).xml pretty: true end |