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.
310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 310 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.
307 308 309 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 307 def edges @edges end |
#node_table ⇒ Object (readonly)
Returns the value of attribute node_table.
307 308 309 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 307 def node_table @node_table end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
307 308 309 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 307 def nodes @nodes end |
#selected ⇒ Object
Returns the value of attribute selected.
308 309 310 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 308 def selected @selected end |
#shift_pressed ⇒ Object
Returns the value of attribute shift_pressed.
308 309 310 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 308 def shift_pressed @shift_pressed end |
#show_index ⇒ Object
Returns the value of attribute show_index.
308 309 310 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 308 def show_index @show_index end |
Instance Method Details
#add_edge(from_id, to_id) ⇒ Object
329 330 331 332 333 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 329 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
322 323 324 325 326 327 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 322 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
335 336 337 338 339 340 341 342 343 344 |
# File 'lib/mk_semi_lattice/sl_components.rb', line 335 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 |