Class: Simp::Cli::Config::YesNoItem
- Defined in:
- lib/simp/cli/config/item.rb
Overview
A Item that asks for lists instead of Strings
note that @value is a Strin
Direct Known Subclasses
Item::IsMasterYumServer, Item::SetGrubPassword, Item::SetupNIC, Item::UseAuditd, Item::UseFips, Item::UseIPtables, Item::UseLdap
Instance Attribute Summary
Attributes inherited from Item
#allow_user_apply, #config_items, #description, #die_on_apply_fail, #fact, #fail_on_missing_answer, #key, #next_items_tree, #silent, #skip_apply, #skip_query, #skip_yaml, #value
Instance Method Summary collapse
-
#highline_question_type ⇒ Object
NOTE: Highline should transform the input to a boolean but doesn’t.
- #next_items ⇒ Object
- #not_valid_message ⇒ Object
-
#to_yaml_s ⇒ Object
NOTE: when used from query_ask, the highline_question_type lamba doesn’t always cast internal type of @value to a boolean.
- #validate(v) ⇒ Object
Methods inherited from Item
#apply, #default_value, #initialize, #os_value, #print_banner, #print_summary, #puppet_value, #query, #query_ask, #query_extras, #query_status, #recommended_value, #safe_apply, #say_blue, #say_green, #say_red, #say_yellow
Constructor Details
This class inherits a constructor from Simp::Cli::Config::Item
Instance Method Details
#highline_question_type ⇒ Object
NOTE: Highline should transform the input to a boolean but doesn’t. Why? REJECTED: Override #query_ask using Highline’s #agree? *** no, can’t bool
236 237 238 239 240 241 242 |
# File 'lib/simp/cli/config/item.rb', line 236 def highline_question_type lambda do |str| return true if ( str =~ /^(y(es)?|true)$/i ? true : false || str.class == TrueClass ) return false if ( str =~ /^(n(o)?|false)$/i ? true : false || str.class == FalseClass ) nil end end |
#next_items ⇒ Object
255 256 257 |
# File 'lib/simp/cli/config/item.rb', line 255 def next_items @next_items_tree.fetch( highline_question_type.call( @value ), [] ) end |
#not_valid_message ⇒ Object
225 226 227 |
# File 'lib/simp/cli/config/item.rb', line 225 def "enter 'yes' or 'no'" end |
#to_yaml_s ⇒ Object
NOTE: when used from query_ask, the highline_question_type lamba doesn’t always cast internal type of @value to a boolean. As a workaround, we cast it here before it is committed to the super’s YAML output.
247 248 249 250 251 252 253 |
# File 'lib/simp/cli/config/item.rb', line 247 def to_yaml_s _value = @value @value = highline_question_type.call @value x = super @value = _value x end |
#validate(v) ⇒ Object
229 230 231 232 |
# File 'lib/simp/cli/config/item.rb', line 229 def validate( v ) return true if (v.class == TrueClass || v.class == FalseClass) ( v =~ /^(y(es)?|true|false|no?)$/i ) ? true : false end |