class Crabfarm::Modes::Shared::InteractiveDecorator::InteractiveHash
Public Class Methods
parse_input(_val)
click to toggle source
# File lib/crabfarm/modes/shared/interactive_decorator.rb, line 15 def self.parse_input(_val) case _val when 'true' then true when 'false' then false when 'nil' then nil when /^\d+$/ then _val.to_i when /^\d*\.\d+$/ then _val.to_f when /^:[^\s]+$/ then _val.to_sym when /^\'.*?\'$/ then _val[1...-1] when /^\".*?\"$/ then _val[1...-1] else _val end end
Public Instance Methods
merge(*args)
click to toggle source
Calls superclass method
# File lib/crabfarm/modes/shared/interactive_decorator.rb, line 35 def merge(*args) InteractiveHash.new.merge! super end
Private Instance Methods
cache()
click to toggle source
# File lib/crabfarm/modes/shared/interactive_decorator.rb, line 41 def cache @cache ||= self.to_h end
cache_value(_key)
click to toggle source
# File lib/crabfarm/modes/shared/interactive_decorator.rb, line 45 def cache_value(_key) unless cache.key? _key value = cache[_key] = Ask.input("Value for '#{_key}'? (blank to skip)".color Colors::QUESTION).strip self[_key] = parse_input value unless value.empty? end end
parse_input(*_args)
click to toggle source
# File lib/crabfarm/modes/shared/interactive_decorator.rb, line 52 def parse_input(*_args) self.class.parse_input(*_args) end