class Dogviz::SigmaGraphHash

Public Class Methods

new(hash) click to toggle source
# File lib/dogviz/sigma_graph_hash.rb, line 5
def initialize(hash)
  hash.each { |k, v|
    self[k] = v
  }
end

Public Instance Methods

output(type_to_filename) click to toggle source
# File lib/dogviz/sigma_graph_hash.rb, line 11
def output(type_to_filename)
  raise StandardError.new('must provide hash (json: somejsonfilename.json)') unless type_to_filename.is_a?(Hash)
  filename = get_json_filename(type_to_filename)
  File.write filename, to_json
end

Private Instance Methods

get_json_filename(type_to_filename) click to toggle source
# File lib/dogviz/sigma_graph_hash.rb, line 19
def get_json_filename(type_to_filename)
  type = type_to_filename.keys.first
  raise StandardError.new("json output only supported, not #{type}") unless type == :json
  type_to_filename[type]
end