Class: Cmdlib::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/cmdlib/option.rb

Overview

Class for create option object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sname, lname, brief = '', param = false) ⇒ Option

Set option shortname (sname) and longname (lname).

Raises:

  • (TypeError)


21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cmdlib/option.rb', line 21

def initialize ( sname, lname, brief = '', param = false )
  raise TypeError, 'Incorrectly types for option constructor.' unless
	sname.instance_of? String and
	lname.instance_of? String and
	brief.instance_of? String

  @shortname = sname
  @longname  = lname
  @brief = brief
  @value = nil
  @param = param
end

Instance Attribute Details

#briefObject

Contain text with describe option (String).



12
13
14
# File 'lib/cmdlib/option.rb', line 12

def brief
  @brief
end

#longnameObject

Contain text with option long name (String).



9
10
11
# File 'lib/cmdlib/option.rb', line 9

def longname
  @longname
end

#paramObject

Contain parameter tag, the option can be have a parameter.



18
19
20
# File 'lib/cmdlib/option.rb', line 18

def param
  @param
end

#shortnameObject

Contain text with option short name (String).



6
7
8
# File 'lib/cmdlib/option.rb', line 6

def shortname
  @shortname
end

#valueObject

Contain option value.



15
16
17
# File 'lib/cmdlib/option.rb', line 15

def value
  @value
end