class JsDuck::Js::Utils

Helpers for handling the parsing of Ext.define definitions

Public Class Methods

make_string(ast) click to toggle source

When the value is string, returns the string, otherwise nil

# File lib/jsduck/js/utils.rb, line 7
def self.make_string(ast)
  str = ast.to_value
  str.is_a?(String) ? str : nil
end
make_string_list(ast) click to toggle source

When the value is string or array of strings, returns array of strings. In any other case, returns empty array.

# File lib/jsduck/js/utils.rb, line 14
def self.make_string_list(ast)
  strings = Array(ast.to_value)
  strings.all? {|s| s.is_a?(String) } ? strings : []
end