Class: Miyako::Diagram::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/Miyako/API/diagram.rb

Overview

遷移図操作クラス

遷移図形式の処理を制御するクラス

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|@diagram| ... } ⇒ Processor

インスタンスを生成する

遷移図形式のインスタンス群を生成する ブロックを必ず取り(取らないとエラー)、ブロック内では、遷移図の構成を実装する (Manager#add, Manager#add_arrow の各メソッドを参照)

返却値

生成されたインスタンス

Yields:



474
475
476
477
478
479
# File 'lib/Miyako/API/diagram.rb', line 474

def initialize
  @states = {:execute => false, :pause => false, :type1 => false }
  @diagram = Miyako::Diagram::Manager.new
  @visible = true
  yield @diagram if block_given?
end

Instance Attribute Details

#diagramObject (readonly)

遷移図本体。Manager クラスのインスタンス



466
467
468
# File 'lib/Miyako/API/diagram.rb', line 466

def diagram
  @diagram
end

#visibleObject

レンダリングの可否(true->描画 false->非描画)



467
468
469
# File 'lib/Miyako/API/diagram.rb', line 467

def visible
  @visible
end

Instance Method Details

#[](name) ⇒ Object

指定した名前のノードを取得する

name

ノード名(文字列・シンボル)

返却値

ノード名に対応したノードのインスタンス



561
562
563
# File 'lib/Miyako/API/diagram.rb', line 561

def [](name)
  return @diagram[name]
end

#disposeObject

各ノードに格納されているインスタンスを解放する



547
548
549
# File 'lib/Miyako/API/diagram.rb', line 547

def dispose
  @diagram.dispose
end

#finish?Boolean

遷移図形式の処理が終了しているかどうかを取得する

遷移図処理が終了したときと停止(Diagram::Processor#stop メソッドを実行)した時に finish? メソッドは true を返す

返却値

処理が終了していれば(開始前ならば) true を返す

Returns:

  • (Boolean)


542
543
544
# File 'lib/Miyako/API/diagram.rb', line 542

def finish?
  @diagram.finish?
end

#initialize_copy(obj) ⇒ Object

:nodocs:



481
482
483
484
# File 'lib/Miyako/API/diagram.rb', line 481

def initialize_copy(obj) #:nodocs:
  @states = @states.dup
  @diagram = @diagram.dup
end

#nodesObject

登録しているノード名のリストを取得する

返却値

ノード名リスト



579
580
581
# File 'lib/Miyako/API/diagram.rb', line 579

def nodes
  return @diagram.nodes
end

#nowObject

現在実行しているノード名を取得する

返却値

ノード名(文字列・シンボル)



567
568
569
# File 'lib/Miyako/API/diagram.rb', line 567

def now
  return @diagram.now
end

#now_nodeObject

現在実行しているノードを取得する

返却値

ノードのインスタンス



573
574
575
# File 'lib/Miyako/API/diagram.rb', line 573

def now_node
  return @diagram.now_node
end

#pauseObject

実行中の処理を停止させる

resume メソッドが呼び出されるまで停止は復帰されない



502
503
504
505
# File 'lib/Miyako/API/diagram.rb', line 502

def pause
  return unless @states[:execute]
  @states[:pause] = true
end

#renderObject

レンダリング処理を行う

現在処理中のノードのrenderメソッドを呼び出す。 visibleメソッドの値がfalseのときは描画されない。



534
535
536
537
# File 'lib/Miyako/API/diagram.rb', line 534

def render
  return unless @visible
  @diagram.render
end

#rendererObject

レンダリングのみのインスタンスを生成する

MVCを推し進めるため、別の場所でレンダリングを行いたい場合に生成する。

返却値

DiagramRenderer クラスのインスタンス



554
555
556
# File 'lib/Miyako/API/diagram.rb', line 554

def renderer
  return Miyako::Diagram::Renderer.new(self.method(:render))
end

#resumeObject

停止状態から復帰する

このメソッドを呼び出すまで停止状態を保つ



509
510
511
512
# File 'lib/Miyako/API/diagram.rb', line 509

def resume
  return unless @states[:execute]
  @states[:pause] = false
end

#startObject

遷移図形式の処理を開始する



487
488
489
490
491
# File 'lib/Miyako/API/diagram.rb', line 487

def start
  return if @states[:execute]
  @diagram.start
  @states[:execute] = true
end

#stopObject

実行中の処理を中断させる



494
495
496
497
498
# File 'lib/Miyako/API/diagram.rb', line 494

def stop
  return unless @states[:execute]
  @diagram.stop
  @states[:execute] = false
end

#update(*params) ⇒ Object

処理の更新を行う

現在処理中のノードupdateメソッドを呼び出す。

params

パラメータ群。省略可能



525
526
527
528
529
# File 'lib/Miyako/API/diagram.rb', line 525

def update(*params)
  return if @states[:pause]
  @diagram.update(*params)
  @states[:execute] = false if @diagram.finish?
end

#update_input(*params) ⇒ Object

入力デバイスに関わる処理を行う

現在処理中のノードのupdate_inputメソッドを呼び出す。

params

パラメータ群。省略可能



517
518
519
520
# File 'lib/Miyako/API/diagram.rb', line 517

def update_input(*params)
  return if @states[:pause]
  @diagram.update_input(*params)
end