Sha256: ddcae7e8721ae9336748f58b85f89e3ac312ab312d3ef668fde4f5663b9ae73a
Contents?: true
Size: 962 Bytes
Versions: 15
Compression:
Stored size: 962 Bytes
Contents
# frozen_string_literal: true require 'pp' module Lino module Utilities def map_and_join(collection, &block) collection.map { |item| block.call(item) }.join(' ') end def join_with(global_separator) lambda do |item| item[:components].join(item[:separator] || global_separator) end end def quote_with(global_character) lambda do |item| item.merge( components: resolve_components(item, global_character) ) end end def missing?(value) value.nil? || (value.respond_to?(:empty?) && value.empty?) end private def resolve_components(item, global_character) components = item[:components] switch = components[0] if components.count > 1 character = item[:quoting] || global_character value = components[1] [switch, "#{character}#{value}#{character}"] else components end end end end
Version data entries
15 entries across 15 versions & 1 rubygems