Class: QED::Demo
Overview
The Demo class ecapsulates a demonstrandum script.
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Demonstrandum file.
-
#mode ⇒ Object
readonly
Parser mode.
Instance Method Summary collapse
-
#applique ⇒ Object
Returns a cached Array of Applique modules.
-
#applique_locations ⇒ Object
Returns a list of applique directories to be used by this demonstrastion.
- #applique_prime ⇒ Object
-
#directory ⇒ Object
Expanded dirname of
file. -
#initialize(file, options = {}) ⇒ Demo
constructor
Steup new Demo instance.
-
#name ⇒ Object
File basename less extension.
-
#parser ⇒ Parser
Get a new Parser instance for this demo.
-
#run(options = {}) ⇒ Object
Run demo through Evaluator instance with given observers.
-
#steps ⇒ Array
(also: #parse)
Demo steps, cached from parsing.
Constructor Details
#initialize(file, options = {}) ⇒ Demo
Steup new Demo instance.
40 41 42 43 44 45 |
# File 'lib/qed/demo.rb', line 40 def initialize(file, ={}) @file = file @mode = [:mode] @applique = [:applique] end |
Instance Attribute Details
#file ⇒ Object (readonly)
Demonstrandum file.
16 17 18 |
# File 'lib/qed/demo.rb', line 16 def file @file end |
#mode ⇒ Object (readonly)
Parser mode.
19 20 21 |
# File 'lib/qed/demo.rb', line 19 def mode @mode end |
Instance Method Details
#applique ⇒ Object
Returns a cached Array of Applique modules.
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/qed/demo.rb', line 58 def applique @applique ||= ( list = [Applique.new] applique_locations.each do |location| #Dir[location + '/**/*'].each do |file| Dir[location + '/*'].each do |file| next if File.directory?(file) list << Applique.for(file) end end list ) end |
#applique_locations ⇒ Object
Returns a list of applique directories to be used by this demonstrastion.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/qed/demo.rb', line 79 def applique_locations @applique_locations ||= ( locations = [] dirpath = Pathname.new(File.dirname(file)) dirpath.ascend do |path| break if path == Dir.pwd dir = File.join(path, 'applique') if File.directory?(dir) locations << dir end end locations ) end |
#applique_prime ⇒ Object
73 74 75 |
# File 'lib/qed/demo.rb', line 73 def applique_prime applique.first end |
#directory ⇒ Object
Expanded dirname of file.
48 49 50 |
# File 'lib/qed/demo.rb', line 48 def directory @directory ||= File.(File.dirname(file)) end |
#name ⇒ Object
File basename less extension.
53 54 55 |
# File 'lib/qed/demo.rb', line 53 def name @name ||= File.basename(file).chomp(File.extname(file)) end |
#parser ⇒ Parser
Get a new Parser instance for this demo.
109 110 111 |
# File 'lib/qed/demo.rb', line 109 def parser Parser.new(self, :mode=>mode) end |
#run(options = {}) ⇒ Object
Run demo through Evaluator instance with given observers.
114 115 116 |
# File 'lib/qed/demo.rb', line 114 def run(={}) Evaluator.run(self, ) end |
#steps ⇒ Array Also known as: parse
Demo steps, cached from parsing.
97 98 99 |
# File 'lib/qed/demo.rb', line 97 def steps @steps ||= parser.parse end |