Class: Excavator::Param

Inherits:
Object
  • Object
show all
Defined in:
lib/excavator/param.rb

Overview

Internal: Param is an object to describe the attributes of a parameter. There’s never a need to instantiate these directly - instead use DSL#param.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Param

Returns a new instance of Param.



22
23
24
25
26
27
28
# File 'lib/excavator/param.rb', line 22

def initialize(name, options = {})
  @name     = name
  @default  = options[:default]
  @optional = options[:optional]
  @desc     = options[:desc]
  @short    = options[:short]
end

Instance Attribute Details

#defaultObject (readonly)

Public: An optional default value for the Param.



13
14
15
# File 'lib/excavator/param.rb', line 13

def default
  @default
end

#descObject (readonly)

Public: An optional String description for the Param.



16
17
18
# File 'lib/excavator/param.rb', line 16

def desc
  @desc
end

#nameObject (readonly)

Public: The String/Symbol name of the Param.



10
11
12
# File 'lib/excavator/param.rb', line 10

def name
  @name
end

#shortObject

Public: An optional String (normally one character) to use as the short switch for the Param.



20
21
22
# File 'lib/excavator/param.rb', line 20

def short
  @short
end

Instance Method Details

#optional?Boolean

Public: Returns whether or not the Param is optional.

Returns a Boolean.

Returns:

  • (Boolean)


40
41
42
# File 'lib/excavator/param.rb', line 40

def optional?
  @default || (@default.nil? && @optional)
end

#required?Boolean

Public: Returns whether or not the Param is required.

Returns a Boolean.

Returns:

  • (Boolean)


33
34
35
# File 'lib/excavator/param.rb', line 33

def required?
  !optional?
end