Class: Inch::CodeObject::Provider::YARD::Docstring
- Inherits:
-
Object
- Object
- Inch::CodeObject::Provider::YARD::Docstring
- Defined in:
- lib/inch/code_object/provider/yard/docstring.rb
Instance Method Summary collapse
- #code_examples ⇒ Object
- #contains_code_example? ⇒ Boolean
- #describes_internal_api? ⇒ Boolean
- #describes_parameter?(name) ⇒ Boolean
- #describes_private_object? ⇒ Boolean
- #describes_return? ⇒ Boolean
- #empty? ⇒ Boolean
-
#initialize(text) ⇒ Docstring
constructor
A new instance of Docstring.
- #mentions_parameter?(name) ⇒ Boolean
- #mentions_return? ⇒ Boolean
- #to_s ⇒ Object
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_examples ⇒ Object
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
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
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
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
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
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
18 19 20 |
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 18 def empty? @text.strip.empty? end |
#mentions_parameter?(name) ⇒ 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
44 45 46 |
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 44 def mentions_return? last_line =~ /^Returns\ / end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/inch/code_object/provider/yard/docstring.rb', line 52 def to_s @text end |