Class: DepsGrapher::Visualizer::JsOption

Inherits:
Object
  • Object
show all
Defined in:
lib/deps_grapher/visualizer/js_option.rb

Defined Under Namespace

Classes: Function

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ JsOption

Returns a new instance of JsOption.



21
22
23
# File 'lib/deps_grapher/visualizer/js_option.rb', line 21

def initialize(hash = {})
  @hash = hash
end

Instance Method Details

#add_function(name:, body:, args: nil) ⇒ Object



25
26
27
28
# File 'lib/deps_grapher/visualizer/js_option.rb', line 25

def add_function(name:, body:, args: nil)
  @hash[name] = Function.new(args: args, body: body)
  self
end

#as_jsonObject



30
31
32
# File 'lib/deps_grapher/visualizer/js_option.rb', line 30

def as_json(*)
  @hash.as_json
end

#to_sObject



34
35
36
# File 'lib/deps_grapher/visualizer/js_option.rb', line 34

def to_s
  as_json.to_json.gsub('"function', "function").gsub('}"', "}")
end