Class: Flow::Flowfile
- Inherits:
-
Object
- Object
- Flow::Flowfile
- Defined in:
- lib/flow-lite.rb
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Class Method Summary collapse
-
.load(code) ⇒ Object
another convenience method - use like Flowfile.load().
-
.load_file(path = './Flowfile') ⇒ Object
convenience method - use like Flowfile.load_file().
Instance Method Summary collapse
- #build_flow_class ⇒ Object
-
#flow ⇒ Object
build flow class.
-
#initialize(opts = {}) ⇒ Flowfile
constructor
A new instance of Flowfile.
- #run(name) ⇒ Object
-
#step(name, &block) ⇒ Object
“classic / basic” primitives - step.
Constructor Details
#initialize(opts = {}) ⇒ Flowfile
Returns a new instance of Flowfile.
97 98 99 100 |
# File 'lib/flow-lite.rb', line 97 def initialize( opts={} ) @opts = opts @steps = [] end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
102 103 104 |
# File 'lib/flow-lite.rb', line 102 def steps @steps end |
Class Method Details
.load(code) ⇒ Object
another convenience method - use like Flowfile.load()
71 72 73 74 75 |
# File 'lib/flow-lite.rb', line 71 def self.load( code ) flowfile = new flowfile.instance_eval( code ) flowfile end |
.load_file(path = './Flowfile') ⇒ Object
convenience method - use like Flowfile.load_file()
65 66 67 68 |
# File 'lib/flow-lite.rb', line 65 def self.load_file( path='./Flowfile' ) code = File.open( path, 'r:utf-8' ) { |f| f.read } load( code ) end |
Instance Method Details
#build_flow_class ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/flow-lite.rb', line 84 def build_flow_class puts "[flow] building flow class..." klass = Class.new( Base ) steps.each do |step| klass.define_step( step ) end klass end |
#flow ⇒ Object
build flow class
79 80 81 82 |
# File 'lib/flow-lite.rb', line 79 def flow ## build flow class @flow_class ||= build_flow_class @flow_class.new ## todo/check: always return a new instance why? why not? end |
#run(name) ⇒ Object
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/flow-lite.rb', line 110 def run( name ) name = name.to_sym ## make sure we always use symbols if flow.respond_to?( name ) flow.send( name ) else puts "!! ERROR: step definition >#{name}< not found; cannot run/execute - known steps include:" pp @steps exit 1 end end |