Sha256: d76831732cbdb4835334899319bc72821708f73a56a51dbaad86d771f59e2c95

Contents?: true

Size: 1.34 KB

Versions: 19

Compression:

Stored size: 1.34 KB

Contents

Entity    = require '../entity'
Parameter = require '../meta/parameter'
Entities  = require '../_entities'
Winston = require 'winston'

module.exports = class Entities.Method extends Entity
  @name: "Method"

  @looksLike: (node) ->
    node.constructor.name == 'Assign' && node.value?.constructor.name == 'Code'

  constructor: (@environment, @file, @node) ->
    Winston.info "Creating new Method Entity" if @environment.options.debug

    @name = [@node.variable.base.value]
    @name.push prop.name.value for prop in @node.variable.properties when prop.name?

    if @name[0] == 'this'
      @selfish = true
      @name    = @name.slice(1)

    if @name[0] == 'module' && @name[1] == 'exports'
      @name = @name.slice(2)

    if @name[0] == 'exports'
      @name = @name.slice(1)

    @name  = @name.join('.')
    @bound = @node.value.bound

    @documentation = @node.documentation

    @parameters = @node.value.params.map (node) ->
      Parameter.fromNode(node)

    if @environment.options.debug
      Winston.info " name: " + @name
      Winston.info " documentation: " + @documentation

  inspect: ->
    {
      file:          @file.path
      name:          @name
      bound:         @bound
      documentation: @documentation?.inspect()
      selfish:       @selfish
      kind:          @kind
      parameters:    @parameters.map (x) -> x.inspect()
    }

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ela-4.1.6 node_modules/codo/lib/entities/method.coffee
ela-4.1.5 node_modules/codo/lib/entities/method.coffee
ela-4.1.4 node_modules/codo/lib/entities/method.coffee
ela-4.1.3 node_modules/codo/lib/entities/method.coffee
ela-4.1.2 node_modules/codo/lib/entities/method.coffee
ela-4.1.1 node_modules/codo/lib/entities/method.coffee
ela-4.1.0 node_modules/codo/lib/entities/method.coffee
ela-4.0.0 node_modules/codo/lib/entities/method.coffee
ela-3.4.3 node_modules/codo/lib/entities/method.coffee
ela-3.4.2 node_modules/codo/lib/entities/method.coffee
ela-3.4.0 node_modules/codo/lib/entities/method.coffee
ela-3.3.1 node_modules/codo/lib/entities/method.coffee
ela-3.3.0 node_modules/codo/lib/entities/method.coffee
ela-3.2.0 node_modules/codo/lib/entities/method.coffee
ela-3.1.1 node_modules/codo/lib/entities/method.coffee
ela-3.1.0 node_modules/codo/lib/entities/method.coffee
ela-3.0.0 node_modules/codo/lib/entities/method.coffee
ela-2.0.0 node_modules/codo/lib/entities/method.coffee
ela-1.1.0 node_modules/codo/lib/entities/method.coffee