Class: Jam_Func::Run

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/Jam_Func.rb

Overview

# ================================================================ # ================== Run (private) =============================== # ================================================================

Constant Summary

Constants included from Helpers

Helpers::WHITE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#canon_name

Constructor Details

#initialize(jam, parent_run, data, arr) ⇒ Run

Returns a new instance of Run.



226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/Jam_Func.rb', line 226

def initialize(jam, parent_run, data, arr)

  @jam        = jam
  @parent_run = parent_run
  @data       = data
  @tasks      = nil

  @proc_list = arr.map { |n|
    n.kind_of?(String) ?
      canon_name(n) :
      n
  }

end

Instance Attribute Details

#errObject (readonly)

Returns the value of attribute err.



224
225
226
# File 'lib/Jam_Func.rb', line 224

def err
  @err
end

#err_nameObject (readonly)

Returns the value of attribute err_name.



224
225
226
# File 'lib/Jam_Func.rb', line 224

def err_name
  @err_name
end

Instance Method Details

#runObject

initialize



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/Jam_Func.rb', line 241

def run
  raise("Already running.") if @tasks

  @tasks = []

  @proc_list.each { |var|
    if var.kind_of? String
      @tasks.push(@jam.entire_list_for(var));
    else
      @tasks.push var
    end
  }

  @tasks = @tasks.flatten

  jam = Jam_Func::Jam.new(@data)

  @tasks.detect { |func|
    is_fine = catch :jam_error do
      args = [jam.data, jam.last, jam].slice(0, func.arity)
      jam._last func.call *args
      true
    end

    !is_fine
  }

  jam
end