class StateDiagram

Attributes

name[RW]

Public Class Methods

new() click to toggle source
# File lib/dibnahs_dogs.rb, line 100
def initialize
  @name = "New State Diagram"
  start = InitialState::new
  start.name = "start"
  start.activity = "initialize"
  @Diagram = Array::new
  @Diagram << start
end

Public Instance Methods

checkSyntax() click to toggle source
# File lib/dibnahs_dogs.rb, line 149
def checkSyntax
tmp = "Check that there is just one start one finish and that all the activities have children"
end
clear() click to toggle source
# File lib/dibnahs_dogs.rb, line 109
def clear
  @Diagram = ""
end
deleteState(name) click to toggle source
# File lib/dibnahs_dogs.rb, line 135
def deleteState(name)
end
draw() click to toggle source
# File lib/dibnahs_dogs.rb, line 141
def draw #self.inspect
  tmp = "#{@name}\n\n"
  @Diagram.each {|a|
    tmp = tmp + "#{a.name}(#{a.serialNo}) \n"
    tmp = tmp + "\tpoints to #{a.pointsTo}\n"
  }
  tmp
end
toRuby() click to toggle source
# File lib/dibnahs_dogs.rb, line 152
def toRuby
  # tmp = "#generate the Mile StateMachine Code\n\nrequire \"MILE/BIN/StateMachine\"\n"
  # tmp = "#generate the Mile StateMachine Code\n\nrequire \"./StateMachine\"\n"
  tmp = "#generate the Mile StateMachine Code\n\nrequire \"dibnahs_dogs\"\n"
  tmp = tmp + "class #{@name}<StateMachine\n  def initialize \n\t#{makeHash}\n    @state = 0\n    self.count = #{@Diagram.size}\n  end\n  def setState(state)\n    case state\n#{makeWhen}    else           puts \"state not found error\"\n    end\n    puts action\n  end\n #{makeAction}end\n"
  tmp
end
updateSate(name) click to toggle source
# File lib/dibnahs_dogs.rb, line 137
def updateSate(name)
  tmp = "make sure you dont delete any thing that has already been written"
  tmp
end

Private Instance Methods

addState(name) click to toggle source
# File lib/dibnahs_dogs.rb, line 127
def addState(name)   
  a = State::new
  a.name = name
  a.activity = name
  @Diagram << a
  tmp = ""
  tmp
end
makeAction() click to toggle source
# File lib/dibnahs_dogs.rb, line 175
def makeAction
  tmp = ""
  @Diagram.each { |a|
    tmp = tmp + "  def #{a.activity}\n    tmp = \"This is where we do state_#{a.name} functionality\"\n    tmp\n  end\n"
  }
  tmp
end
makeHash() click to toggle source
# File lib/dibnahs_dogs.rb, line 159
def makeHash
  tmp =    " @hash = {\n\t"
  @Diagram.each { |a|
    tmp = tmp + " '#{a.activity}' => #{a.serialNo},\n\t"
  }
  #REMOVE THE LAST , /\,/Start from the right =8=
  tmp = tmp + "\t}  "
  tmp
end
makeWhen() click to toggle source
# File lib/dibnahs_dogs.rb, line 168
def makeWhen
  tmp = ""
  @Diagram.each { |a|
    tmp = tmp + "\twhen state = @hash['#{a.activity}']    then action = #{a.activity}\n"
  }
  tmp
end