class YARD::Tags::TypesExplainer::Type

@private

Attributes

name[RW]

Public Class Methods

new(name) click to toggle source
# File lib/yard/tags/types_explainer.rb, line 29
def initialize(name)
  @name = name
end

Public Instance Methods

to_s(singular = true) click to toggle source
# 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

Private Instance Methods

list_join(list) click to toggle source
# File lib/yard/tags/types_explainer.rb, line 45
def list_join(list)
  index = 0
  list.inject(String.new) do |acc, el|
    acc << el.to_s
    acc << ", " if index < list.size - 2
    acc << " or " if index == list.size - 2
    index += 1
    acc
  end
end