Class: DepsGrapher::Visualizer::JsOption
- Inherits:
-
Object
- Object
- DepsGrapher::Visualizer::JsOption
- Defined in:
- lib/deps_grapher/visualizer/js_option.rb
Defined Under Namespace
Classes: Function
Instance Method Summary collapse
- #add_function(name:, body:, args: nil) ⇒ Object
- #as_json ⇒ Object
-
#initialize(hash = {}) ⇒ JsOption
constructor
A new instance of JsOption.
- #to_s ⇒ Object
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_json ⇒ Object
30 31 32 |
# File 'lib/deps_grapher/visualizer/js_option.rb', line 30 def as_json(*) @hash.as_json end |
#to_s ⇒ Object
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 |