class Ruboty::Variable::Actions::ArrayRemove
Public Instance Methods
call(key, values)
click to toggle source
# File lib/ruboty/variable/actions/array_remove.rb, line 5 def call(key, values) case var.type(key) when 'array' values.split(/\s+/).each {|value| remove(key, value)} when nil message.reply(undefined_message(key)) else message.reply(type_error_message(key)) end end
not_found_message(key, value)
click to toggle source
# File lib/ruboty/variable/actions/array_remove.rb, line 29 def not_found_message(key, value) "#{value} is not found in #{key}" end
remove(key, value)
click to toggle source
# File lib/ruboty/variable/actions/array_remove.rb, line 16 def remove(key, value) if var.array_include?(key, value) var.array_remove(key, value) message.reply(remove_message(key, value)) else message.reply(not_found_message(key, value)) end end
remove_message(key, value)
click to toggle source
# File lib/ruboty/variable/actions/array_remove.rb, line 25 def remove_message(key, value) "Remove #{value} from #{key}" end
type_error_message(key)
click to toggle source
# File lib/ruboty/variable/actions/array_remove.rb, line 33 def type_error_message(key) "#{key} is not array type" end
undefined_message(key)
click to toggle source
# File lib/ruboty/variable/actions/array_remove.rb, line 37 def undefined_message(key) "Undefined #{key}" end