Class: DocStat::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/docstat/token.rb

Constant Summary collapse

METHOD_TYPES =
['clm','clfm','instm','intfm']
PROPERTY_TYPES =
['instp','intfp']
TYPE_MAPPING =
{
  'clm' => 'class method',
  'clfm' => 'class category method',
  'instm' => 'instance method',
  'intfm' => 'instance method',
  'instp' => 'instance property',
  'intfp' => 'instance property'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(property_ary) ⇒ Token

Returns a new instance of Token.



17
18
19
# File 'lib/docstat/token.rb', line 17

def initialize property_ary
  _, @name, @type, @abstract, @declaration, @return_value = *property_ary
end

Instance Attribute Details

#abstractObject (readonly)

Returns the value of attribute abstract.



4
5
6
# File 'lib/docstat/token.rb', line 4

def abstract
  @abstract
end

#declarationObject (readonly)

Returns the value of attribute declaration.



4
5
6
# File 'lib/docstat/token.rb', line 4

def declaration
  @declaration
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/docstat/token.rb', line 4

def name
  @name
end

#return_valueObject (readonly)

Returns the value of attribute return_value.



4
5
6
# File 'lib/docstat/token.rb', line 4

def return_value
  @return_value
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/docstat/token.rb', line 4

def type
  @type
end

Instance Method Details

#descriptionObject



49
50
51
# File 'lib/docstat/token.rb', line 49

def description
  "#{name} (#{type}) - #{abstract}"
end

#documented?Boolean

Returns:

  • (Boolean)


32
33
34
35
# File 'lib/docstat/token.rb', line 32

def documented?
  # TODO: check parameter docs as well?
  !((abstract.nil? || abstract.empty?) && (return_value.nil? || return_value.empty?))
end

#method?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/docstat/token.rb', line 37

def method?
  METHOD_TYPES.include?(type)
end

#pretty_typeObject



45
46
47
# File 'lib/docstat/token.rb', line 45

def pretty_type
  TYPE_MAPPING[type]
end

#property?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/docstat/token.rb', line 41

def property?
  PROPERTY_TYPES.include?(type)
end

#to_hashObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/docstat/token.rb', line 21

def to_hash
  {
    "name" => name,
    "type" => pretty_type,
    "abstract" => abstract,
    "declaration" => declaration,
    "returns" => return_value,
    "documented" => documented?
  }
end