Class: Description::Text
- Inherits:
-
Treetop::Runtime::SyntaxNode
- Object
- Treetop::Runtime::SyntaxNode
- Description::Text
- Includes:
- Enumerable
- Defined in:
- lib/pdoc/parser/description_nodes.rb
Instance Method Summary collapse
- #each ⇒ Object
- #excerpt ⇒ Object
- #inspect ⇒ Object
- #join(sep = "\n") ⇒ Object
- #outdent ⇒ Object
- #to_s ⇒ Object
- #truncate(num = 30) ⇒ Object
Instance Method Details
#each ⇒ Object
4 5 6 |
# File 'lib/pdoc/parser/description_nodes.rb', line 4 def each elements.map { |e| e.to_s }.each { |tag| yield tag } end |
#excerpt ⇒ Object
16 17 18 |
# File 'lib/pdoc/parser/description_nodes.rb', line 16 def excerpt end |
#inspect ⇒ Object
20 21 22 23 |
# File 'lib/pdoc/parser/description_nodes.rb', line 20 def inspect text = truncate(15).gsub(/\n/, " ").strip.inspect "#<#{self.class} #{text}>" end |
#join(sep = "\n") ⇒ Object
8 9 10 |
# File 'lib/pdoc/parser/description_nodes.rb', line 8 def join(sep = "\n") outdent.join(sep).strip end |
#outdent ⇒ Object
29 30 31 32 |
# File 'lib/pdoc/parser/description_nodes.rb', line 29 def outdent range = tab_length..-1 map { |l| l.slice(range) } end |
#to_s ⇒ Object
12 13 14 |
# File 'lib/pdoc/parser/description_nodes.rb', line 12 def to_s join end |
#truncate(num = 30) ⇒ Object
25 26 27 |
# File 'lib/pdoc/parser/description_nodes.rb', line 25 def truncate(num = 30) to_s.length < num ? to_s : to_s.slice(0..num) << "..." end |