Sha256: db5f27a86a7f2c2fb320f185ad661666f3728a3f9dfd4af3ecbf8293304f9c5f

Contents?: true

Size: 829 Bytes

Versions: 5

Compression:

Stored size: 829 Bytes

Contents

require "jsduck/tag/class_list_tag"

module JsDuck::Tag
  class Implements < ClassListTag
    def initialize
      @pattern = ["implements", "implement"]
      @tagname = :implements
      @repeatable = true
      @ext_define_pattern = "implements"
      @ext_define_default = {:implements => []}
    end

    # Override definition in parent class.  In addition to Array
    # literal, implements can be defined with an object literal.
    def parse_ext_define(cls, ast)
      cls[:implements] = to_implements_array(ast)
    end

    # converts AstNode, whether it's a string, array or hash into
    # array of strings (when possible).
    def to_implements_array(ast)
      v = ast.to_value
      implements = v.is_a?(Hash) ? v.values : Array(v)
      implements.all? {|mx| mx.is_a? String } ? implements : []
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jsduck-troopjs-0.0.10 lib/jsduck/tag/implements.rb
jsduck-troopjs-0.0.9 lib/jsduck/tag/implements.rb
jsduck-troopjs-0.0.8 lib/jsduck/tag/implements.rb
jsduck-troopjs-0.0.7 lib/jsduck/tag/implements.rb
jsduck-troopjs-0.0.5 lib/jsduck/tag/implements.rb