Class: SLComponents::BuildViewer
- Inherits:
-
Object
- Object
- SLComponents::BuildViewer
- Defined in:
- lib/mk_semi_lattice/sl_components.rb
Overview
SLComponents::GraphData はノードとエッジのデータをYAMLファイルから読み込み作成
Instance Attribute Summary collapse
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
-
#node_table ⇒ Object
readonly
Returns the value of attribute node_table.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
-
#selected ⇒ Object
Returns the value of attribute selected.
-
#shift_pressed ⇒ Object
Returns the value of attribute shift_pressed.
-
#show_index ⇒ Object
Returns the value of attribute show_index.
Instance Method Summary collapse
- #add_edge(from_id, to_id) ⇒ Object
- #add_node(node_data) ⇒ Object
-
#initialize(file = "dir_node_edge.yaml", options) ⇒ BuildViewer
constructor
A new instance of BuildViewer.
- #load_yaml_data_with_state(path, with_semi_lattice_yaml: false) ⇒ Object
Constructor Details
#initialize(file = "dir_node_edge.yaml", options) ⇒ BuildViewer
Returns a new instance of BuildViewer.
313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 313 def initialize(file = "dir_node_edge.yaml", ) with_semi_lattice_yaml = [:with_semi_lattice_yaml] show_index = [:show_index] @nodes = [] @edges = [] @node_table = {} @selected = nil @shift_pressed = false @show_index = show_index load_yaml_data_with_state(file, with_semi_lattice_yaml: with_semi_lattice_yaml) end |
Instance Attribute Details
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
310 311 312 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 310 def edges @edges end |
#node_table ⇒ Object (readonly)
Returns the value of attribute node_table.
310 311 312 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 310 def node_table @node_table end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
310 311 312 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 310 def nodes @nodes end |
#selected ⇒ Object
Returns the value of attribute selected.
311 312 313 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 311 def selected @selected end |
#shift_pressed ⇒ Object
Returns the value of attribute shift_pressed.
311 312 313 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 311 def shift_pressed @shift_pressed end |
#show_index ⇒ Object
Returns the value of attribute show_index.
311 312 313 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 311 def show_index @show_index end |
Instance Method Details
#add_edge(from_id, to_id) ⇒ Object
332 333 334 335 336 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 332 def add_edge(from_id, to_id) from = @node_table[from_id] to = @node_table[to_id] @edges << Edge.new(from, to) if from && to end |
#add_node(node_data) ⇒ Object
325 326 327 328 329 330 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 325 def add_node(node_data) return if node_data[:id].nil? n = Node.new(node_data) @nodes << n @node_table[node_data[:id]] = n end |
#load_yaml_data_with_state(path, with_semi_lattice_yaml: false) ⇒ Object
338 339 340 341 342 343 344 345 346 347 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 338 def load_yaml_data_with_state(path, with_semi_lattice_yaml: false) state_file = path data = if with_semi_lattice_yaml && File.exist?(state_file) YAML.load_file(state_file) else YAML.load_file(path, symbolize_names: true) end #p data load_nodes_and_edges(data) end |