Class: RProgram::NonOption

Inherits:
Argument show all
Defined in:
lib/rprogram/non_option.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Argument

#arguments

Constructor Details

#initialize(options = {}) ⇒ NonOption

Creates a new NonOption object.

Parameters:

  • options (Hash) (defaults to: {})

    Additional options.

Options Hash (options):

  • :name (Symbol)

    The name of the non-option.

  • :leading (true, false) — default: true

    Implies the non-option is a leading non-option.

  • :tailing (false, true) — default: false

    Implies the non-option is a tailing non-option.

  • :multiple (false, true) — default: false

    Implies the non-option maybe given an Array of values.



30
31
32
33
34
35
36
37
38
39
# File 'lib/rprogram/non_option.rb', line 30

def initialize(options={})
  @name = options[:name]

  @tailing = if    options[:leading] then !options[:leading]
             elsif options[:tailing] then options[:tailing]
             else                         true
             end

  @multiple = (options[:multiple] || false)
end

Instance Attribute Details

#multipleObject (readonly)

Can the argument be specified multiple times



10
11
12
# File 'lib/rprogram/non_option.rb', line 10

def multiple
  @multiple
end

#nameObject (readonly)

Name of the argument(s)



7
8
9
# File 'lib/rprogram/non_option.rb', line 7

def name
  @name
end

Instance Method Details

#leading?true, false

Determines whether the non-option's arguments are leading.

Returns:

  • (true, false)

    Specifies whether the non-option's arguments are leading.



57
58
59
# File 'lib/rprogram/non_option.rb', line 57

def leading?
  !(@tailing)
end

#tailing?true, false

Determines whether the non-option's arguments are tailing.

Returns:

  • (true, false)

    Specifies whether the non-option's arguments are tailing.



47
48
49
# File 'lib/rprogram/non_option.rb', line 47

def tailing?
  @tailing == true
end