class Ruboty::Variable::Actions::ArrayPush
Public Instance Methods
call(key, values)
click to toggle source
# File lib/ruboty/variable/actions/array_push.rb, line 5 def call(key, values) case var.type(key) when 'array' values.split(/\s+/).each {|value| push(key, value)} when nil message.reply(undefined_message(key)) else message.reply(type_error_message(key)) end end
included_message(key, value)
click to toggle source
# File lib/ruboty/variable/actions/array_push.rb, line 25 def included_message(key, value) "#{key} already included #{value}" end
push(key, value)
click to toggle source
# File lib/ruboty/variable/actions/array_push.rb, line 16 def push(key, value) if var.array_include?(key, value) message.reply(included_message(key, value)) else var.array_push(key, value) message.reply(push_message(key, value)) end end
push_message(key, value)
click to toggle source
# File lib/ruboty/variable/actions/array_push.rb, line 29 def push_message(key, value) "Push #{value} to #{key}" end
type_error_message(key)
click to toggle source
# File lib/ruboty/variable/actions/array_push.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_push.rb, line 37 def undefined_message(key) "Undefined #{key}" end