Class: MissionStrategy

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/mission_strategy.rb

Overview

This class describes a strategy of mission.

Defined Under Namespace

Classes: JobTypeStrategy, SquadStrategy

Instance Method Summary (collapse)

Instance Method Details

- (Object) eval_script

Execute instance_eval() by MissionStrategy.script.



81
82
83
84
85
86
# File 'app/models/mission_strategy.rb', line 81

def eval_script
  @initialized_flg = true
  @jobtypes = Hash.new
  @squads = Hash.new
  instance_eval(script.gsub("\r\n", ";"))
end

- (Boolean) initialized?

Return the status whether eval_script method has been called or not.

Returns:

  • (Boolean)

    eval_script status.



90
91
92
93
94
95
96
# File 'app/models/mission_strategy.rb', line 90

def initialized?
  if @initialized_flg
    return true
  else
    return false
  end
end

- (Object) jobtype(symbol)

Return the job type which was evaluated from script.

Parameters:

  • symbol (Integer)

Returns:

  • (Object)

    job type



101
102
103
104
# File 'app/models/mission_strategy.rb', line 101

def jobtype(symbol)
  @jobtypes[symbol] = JobTypeStrategy.new(symbol) if @jobtypes[symbol].nil?
  return @jobtypes[symbol]
end

- (Object) squad(index)

Return the squad which was evaluated from script.

Parameters:

  • index (Integer)

Returns:

  • (Object)

    squad



109
110
111
112
# File 'app/models/mission_strategy.rb', line 109

def squad(index)
  @squads[index] = SquadStrategy.new(index, 1) if @squads[index].nil?
  return @squads[index]
end