Class: OrigenTesters::ATP::Program
- Inherits:
-
Object
- Object
- OrigenTesters::ATP::Program
- Defined in:
- lib/origen_testers/atp/program.rb
Overview
Program is the top-level container for a collection of test flows
Class Method Summary collapse
-
.load(file) ⇒ Object
Load a program from a previously saved file.
Instance Method Summary collapse
- #flow(name, options = {}) ⇒ Object
- #flows ⇒ Object
-
#method_missing(method, *args, &block) ⇒ Object
:nodoc:.
- #respond_to?(*args) ⇒ Boolean
-
#save(file) ⇒ Object
Save the program to a file.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
:nodoc:
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/origen_testers/atp/program.rb', line 37 def method_missing(method, *args, &block) # :nodoc: if f = flows[method] define_singleton_method method do f end f else super end end |
Class Method Details
.load(file) ⇒ Object
Load a program from a previously saved file
5 6 7 8 9 10 11 |
# File 'lib/origen_testers/atp/program.rb', line 5 def self.load(file) p = nil File.open(file) do |f| p = Marshal.load(f) end p end |
Instance Method Details
#flow(name, options = {}) ⇒ Object
13 14 15 |
# File 'lib/origen_testers/atp/program.rb', line 13 def flow(name, = {}) flows[name] ||= Flow.new(self, name, ) end |
#flows ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/origen_testers/atp/program.rb', line 17 def flows @flows ||= {}.with_indifferent_access # To rescue previously created programs which have been loaded unless @flows.is_a?(ActiveSupport::HashWithIndifferentAccess) @flows = @flows.with_indifferent_access end @flows end |
#respond_to?(*args) ⇒ Boolean
33 34 35 |
# File 'lib/origen_testers/atp/program.rb', line 33 def respond_to?(*args) flows.key?(args.first) || super end |
#save(file) ⇒ Object
Save the program to a file
27 28 29 30 31 |
# File 'lib/origen_testers/atp/program.rb', line 27 def save(file) File.open(file, 'w') do |f| Marshal.dump(self, f) end end |