Class: Inch::CodeObject::Provider::YARD::Docstring

Inherits:
Object
  • Object
show all
Defined in:
lib/inch/code_object/provider/yard/docstring.rb

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Docstring

Returns a new instance of Docstring.



6
7
8
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 6

def initialize(text)
  @text = text.to_s
end

Instance Method Details

#code_examplesObject



26
27
28
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 26

def code_examples
  @code_examples ||= parse_code_examples
end

#contains_code_example?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 22

def contains_code_example?
  !code_examples.empty?
end

#describes_internal_api?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 10

def describes_internal_api?
  first_line =~ /^Internal\:\ .+/
end

#describes_parameter?(name) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 30

def describes_parameter?(name)
  return false if name.nil?
  describe_parameter_regexps(name).any? do |pattern|
    @text.index(pattern)
  end
end

#describes_private_object?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 14

def describes_private_object?
  first_line =~ /^Private\:\ .+/
end

#describes_return?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 48

def describes_return?
  last_line =~ /^Returns\ (\w+\s){2,}/
end

#empty?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 18

def empty?
  @text.strip.empty?
end

#mentions_parameter?(name) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
41
42
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 37

def mentions_parameter?(name)
  return false if name.nil?
  mention_parameter_regexps(name).any? do |pattern|
    @text.index(pattern)
  end
end

#mentions_return?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 44

def mentions_return?
  last_line =~ /^Returns\ /
end

#to_sObject



52
53
54
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 52

def to_s
  @text
end