Class: YARD::Tags::TypesExplainer::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/tags/types_explainer.rb

Direct Known Subclasses

CollectionType, HashCollectionType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Type

Returns a new instance of Type.



29
30
31
# File 'lib/yard/tags/types_explainer.rb', line 29

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



27
28
29
# File 'lib/yard/tags/types_explainer.rb', line 27

def name
  @name
end

Instance Method Details

#to_s(singular = true) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/yard/tags/types_explainer.rb', line 33

def to_s(singular = true)
  if name[0, 1] == "#"
    singular ? "an object that responds to #{name}" : "objects that respond to #{name}"
  elsif name[0, 1] =~ /[A-Z]/
    singular ? "a#{name[0, 1] =~ /[aeiou]/i ? 'n' : ''} " + name : "#{name}#{name[-1, 1] =~ /[A-Z]/ ? "'" : ''}s"
  else
    name
  end
end