Class: RedGrape::GraphStore

Inherits:
Object show all
Defined in:
lib/red_grape/graph_store.rb

Direct Known Subclasses

Tools::Trellis

Instance Method Summary collapse

Constructor Details

#initializeGraphStore

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

Raises:

  • (ArgumentError)


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_namesObject



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