Class: JsDuck::Js::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/jsduck/js/utils.rb

Overview

Helpers for handling the parsing of Ext.define definitions

Class Method Summary collapse

Class Method Details

.make_string(ast) ⇒ Object

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



7
8
9
10
# 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) ⇒ Object

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



14
15
16
17
# 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