Method: Loquacious::Configuration::Help#show_attribute

Defined in:
lib/loquacious/configuration/help.rb

#show_attribute(name = nil, opts = {}) ⇒ Object Also known as: show

call-seq:

show_attribute( name = nil, opts = {} )

Use this method to show the description for a single attribute or for all the attributes if no name is given. The options allow you to show the values along with the attributes and to hide the descriptions (if all you want to see are the values).

:descriptions => true to show descriptions and false to hide them
:values       => true to show values and false to hide them


134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/loquacious/configuration/help.rb', line 134

def show_attribute( name = nil, opts = {} )
  name, opts = nil, name if name.is_a?(Hash)
  opts = {
    :descriptions => true,
    :values => false
  }.merge!(opts)

  rgxp = Regexp.new(normalize_attr(name))
  show_description = opts[:descriptions]
  show_value = opts[:values]

  Iterator.new(@config).each do |node|
    next unless rgxp =~ node.name
    next if !show_nesting_nodes? and node.config?
    print_node(node, show_description, show_value)
  end
end