module TheGame::Helpers::StringHelpers
Constants
- FALSE_WORDS
- TRUE_WORDS
Public Instance Methods
args()
click to toggle source
# File lib/the_game/helpers/string.rb, line 21 def args strip! words.map do |arg| arg = arg.to_s next if arg.empty? arg.bool? ? arg.to_bool : arg.numeric? ? Float(arg) : arg end end
args?()
click to toggle source
# File lib/the_game/helpers/string.rb, line 31 def args? !args.empty? end
bool?()
click to toggle source
# File lib/the_game/helpers/string.rb, line 17 def bool? !to_bool.nil? end
command_sanitize()
click to toggle source
# File lib/the_game/helpers/string.rb, line 9 def command_sanitize sub(/^_+/, '') end
numeric?()
click to toggle source
# File lib/the_game/helpers/string.rb, line 5 def numeric? !!Float(self) rescue false end
remove_first_word()
click to toggle source
# File lib/the_game/helpers/string.rb, line 39 def remove_first_word gsub(/^\S+\s*/,'') end
to_bool()
click to toggle source
# File lib/the_game/helpers/string.rb, line 13 def to_bool TRUE_WORDS.include?(downcase) ? true : FALSE_WORDS.include?(downcase) ? false : nil end
words()
click to toggle source
# File lib/the_game/helpers/string.rb, line 35 def words scan(/\S+/) end