Class: Lazydoc::Arguments
- Defined in:
- lib/lazydoc/arguments.rb
Overview
A special type of self-resolving Method that whose to_s returns arguments formatted for the command line.
a = Arguments.new
a.subject = "def method(a, b='default', *c, &d)"
a.to_s # => "A B='default' C..."
Constant Summary
Constants inherited from Method
Instance Attribute Summary
Attributes inherited from Method
Attributes inherited from Comment
#content, #document, #line_number, #subject
Instance Method Summary collapse
-
#to_s ⇒ Object
Self-resolves and returns arguments formatted for the command line.
Methods inherited from Method
Methods inherited from Comment
#<<, #append, #comment, #empty?, #initialize, #parse_down, #parse_up, #prepend, #push, #resolve, #trailer, #trim, #unshift, #value, #value=, #wrap
Methods included from Utils
categorize, convert_to_scanner, determine_line_number, match_index, scan, scan_args, scan_index, scan_trailer, skip_quote, split_lines, wrap
Constructor Details
This class inherits a constructor from Lazydoc::Method
Instance Method Details
#to_s ⇒ Object
Self-resolves and returns arguments formatted for the command line.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/lazydoc/arguments.rb', line 13 def to_s resolve arguments.collect do |arg| case arg when /^&/ then nil when /^\*/ then "#{arg[1..-1].upcase }..." when /^(.*?)=(.*)$/ then "#{$1.upcase}=#{$2}" else arg.upcase end end.compact.join(' ') end |