Class: Fylla::ParsedOption

Inherits:
Object
  • Object
show all
Defined in:
lib/fylla/parsed_option.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, description, aliases, enum, filter, type) ⇒ ParsedOption

Returns a new instance of ParsedOption.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fylla/parsed_option.rb', line 8

def initialize(name, description, aliases, enum, filter, type)
  @name = name
  @description = description
  @aliases = aliases
  # used for switches that take values (everything, but not necessary for boolean)
  @equals_type = type == :boolean ? "" : "="
  @action = ""
  return unless enum

  case type
  when :array
    @action = if filter
                %(: :_values -s , 'options' #{enum.join(" ")})
              else
                %(: :_sequence -d compadd - #{enum.join(" ")})
              end
  when :string
    @action = %|: :(#{enum.join(" ")})|
  end
end

Instance Attribute Details

#actionObject (readonly)

used just for parsing class_options recursively. Don’t ever set these. used for erb file action



6
7
8
# File 'lib/fylla/parsed_option.rb', line 6

def action
  @action
end

#aliasesObject

Returns the value of attribute aliases.



3
4
5
# File 'lib/fylla/parsed_option.rb', line 3

def aliases
  @aliases
end

used just for parsing class_options recursively. Don’t ever set these. used for erb file action



6
7
8
# File 'lib/fylla/parsed_option.rb', line 6

def banner
  @banner
end

#completionObject (readonly)

used just for parsing class_options recursively. Don’t ever set these. used for erb file action



6
7
8
# File 'lib/fylla/parsed_option.rb', line 6

def completion
  @completion
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/fylla/parsed_option.rb', line 3

def description
  @description
end

#enumObject (readonly)

used just for parsing class_options recursively. Don’t ever set these. used for erb file action



6
7
8
# File 'lib/fylla/parsed_option.rb', line 6

def enum
  @enum
end

#equals_typeObject (readonly)

used just for parsing class_options recursively. Don’t ever set these. used for erb file action



6
7
8
# File 'lib/fylla/parsed_option.rb', line 6

def equals_type
  @equals_type
end

#filterObject (readonly)

used just for parsing class_options recursively. Don’t ever set these. used for erb file action



6
7
8
# File 'lib/fylla/parsed_option.rb', line 6

def filter
  @filter
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/fylla/parsed_option.rb', line 3

def name
  @name
end

#typeObject (readonly)

used just for parsing class_options recursively. Don’t ever set these. used for erb file action



6
7
8
# File 'lib/fylla/parsed_option.rb', line 6

def type
  @type
end