Sha256: 4f4af7f62435b917e75047dd2d380c9ab40531bb2d1527a9bdf1e7c4075434eb
Contents?: true
Size: 1.21 KB
Versions: 41
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module Doing ## ## Array helpers ## module ArrayTags ## ## Convert an array of @tags to plain strings ## ## @return [Array] array of strings without @ symbols ## ## @example Convert an array of tags to strings ## ['@one', '@two', 'three'].to_tags => ['one', 'two', 'three'] def tags_to_array map(&:remove_at).map(&:strip) end # Convert array of strings to array of @tags # # @return [Array] Array of @tags # # @example Convert an array of strings with or without @ symbols # ['one', '@two', 'three'].to_tags => ['@one', '@two', '@three'] def to_tags map(&:add_at) end ## ## Hightlight @tags in string for console output ## ## @param color [String] the color to highlight ## with ## ## @return [Array] Array of highlighted @tags ## def highlight_tags(color = 'cyan') to_tags.map { |t| Doing::Color.send(color.to_sym, t) } end ## ## Tag array for logging ## ## @return [String] Highlighted tag array joined with comma ## def log_tags(color = 'cyan') highlight_tags(color).join(', ') end end end
Version data entries
41 entries across 41 versions & 1 rubygems