Class: DepsGrapher::Visualizer::JsOption::Function

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

Instance Method Summary collapse

Constructor Details

#initialize(body:, args: nil) ⇒ Function

Returns a new instance of Function.



7
8
9
10
# File 'lib/deps_grapher/visualizer/js_option.rb', line 7

def initialize(body:, args: nil)
  @args = args
  @body = body
end

Instance Method Details

#as_jsonObject



12
13
14
15
16
17
18
# File 'lib/deps_grapher/visualizer/js_option.rb', line 12

def as_json(*)
  <<~JS.split(/$/).map(&:strip).compact_blank.join(";")
    function(#{Array(@args).join(", ")}) {
      #{@body}
    }
  JS
end