Class: RedGrape::GraphStore
Direct Known Subclasses
Instance Method Summary collapse
- #<<(graph) ⇒ Object
- #graph(key) ⇒ Object (also: #[])
- #graph_names ⇒ Object
-
#initialize ⇒ GraphStore
constructor
A new instance of GraphStore.
- #put_graph(key, graph) ⇒ Object (also: #[]=)
Constructor Details
#initialize ⇒ GraphStore
Returns a new instance of GraphStore.
5 6 7 |
# File 'lib/red_grape/graph_store.rb', line 5 def initialize @graphs = {} end |
Instance Method Details
#<<(graph) ⇒ Object
24 25 26 27 |
# File 'lib/red_grape/graph_store.rb', line 24 def <<(graph) raise ArgumentError.new('The given graph does not have its name.') unless graph.name @graphs[graph.name.to_sym] = graph end |
#graph(key) ⇒ Object Also known as: []
13 14 15 |
# File 'lib/red_grape/graph_store.rb', line 13 def graph(key) @graphs[key.to_s.to_sym] end |
#graph_names ⇒ Object
9 10 11 |
# File 'lib/red_grape/graph_store.rb', line 9 def graph_names @graphs.keys.sort end |
#put_graph(key, graph) ⇒ Object Also known as: []=
18 19 20 21 |
# File 'lib/red_grape/graph_store.rb', line 18 def put_graph(key, graph) graph.name = key.to_s.to_sym self << graph end |