class Birdwatcher::Commands::Set
Constants
- FALSY_VALUES
- TRUTHY_VALUES
Public Instance Methods
run()
click to toggle source
# File lib/birdwatcher/commands/set.rb, line 13 def run if arguments.count < 2 error("You must provide an option name and value") return false end if !current_module error("No module loaded") return false end option, value = arguments.first.upcase, arguments[1..-1].join(" ") if !current_module.meta[:options].keys.include?(option) error("Unknown option: #{option.bold}") return false end if current_module.meta[:options][option][:boolean] if truthy?(value) value = true elsif falsy?(value) value = false end end current_module.meta[:options][option][:value] = value end
Private Instance Methods
current_module()
click to toggle source
# File lib/birdwatcher/commands/set.rb, line 51 def current_module console.current_module end
falsy?(value)
click to toggle source
# File lib/birdwatcher/commands/set.rb, line 47 def falsy?(value) FALSY_VALUES.include?(value.downcase) end
truthy?(value)
click to toggle source
# File lib/birdwatcher/commands/set.rb, line 43 def truthy?(value) TRUTHY_VALUES.include?(value.downcase) end