Class Clio::Usage::Argument
In: lib/clio/usage/argument.rb
Parent: Object

Usage Argument

TODO: Should argument have name in addition to type?

Methods

help   initialize_copy   inspect   new   splat   to_s   type  

Attributes

help  [R] 
splat  [R] 
type  [R]  attr :parent attr :name

Public Class methods

New Argument.

[Source]

# File lib/clio/usage/argument.rb, line 16
      def initialize(type, &block)
        @type      = type
        #@name      = type.downcase if type.upcase != type
        @splat     = false
        @help      = ''
        instance_eval(&block) if block
      end

Public Instance methods

Specify help text for argument.

[Source]

# File lib/clio/usage/argument.rb, line 62
      def help(string=nil)
        @help.replace(string.to_s) if string
        @help
      end

[Source]

# File lib/clio/usage/argument.rb, line 25
      def initialize_copy(o)
        #@name = o.name.dup
        @type = o.type.dup
        @help = o.help.dup
      end

[Source]

# File lib/clio/usage/argument.rb, line 73
      def inspect
        to_s
        #s  = "<#{name}"
        #s << ":#{type.inspect}" if type
        #s << ">"
        #s
      end

[Source]

# File lib/clio/usage/argument.rb, line 56
      def splat(true_or_false=nil)
        return @splat if true_or_false.nil?
        @splat = true_or_false
      end

[Source]

# File lib/clio/usage/argument.rb, line 67
      def to_s
        s = "<#{type}"
        s << (splat ? "...>" : ">")
        s
      end

Specify the type of the argument. This is an arbitrary description of the type. The value given is converted to uppercase.

  arg.type('file')
  arg.type #=> 'FILE'

[Source]

# File lib/clio/usage/argument.rb, line 43
      def type(string=nil)
        return @type unless string
        @type = string.to_s.upcase
        self
      end

[Validate]