Sha256: 10675cb7368d157a76cc6e41955cfe821d75d17472330c7103b4aef6555e0627

Contents?: true

Size: 581 Bytes

Versions: 12

Compression:

Stored size: 581 Bytes

Contents

module Lookbook
  module Utils
    class << self
      def id(*args)
        parts = args.map { |arg| arg.to_s }
        id_str = parts.join("-").force_encoding("UTF-8").parameterize.dasherize
        PathUtils.strip_slashes(id_str).tr("/", "-").gsub("--", "-")
      end

      def name(str)
        str.to_s.parameterize.tr("-", "_")
      end

      def value_or_fallback(value, fallback = nil, &block)
        if value.nil?
          fallback_block = block || proc { fallback }
          fallback_block.call
        else
          value
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
lookbook-1.5.5 lib/lookbook/support/utils/utils.rb
lookbook-1.5.4 lib/lookbook/support/utils/utils.rb
lookbook-1.5.3 lib/lookbook/support/utils/utils.rb
lookbook-1.5.2 lib/lookbook/support/utils/utils.rb
lookbook-1.5.1 lib/lookbook/support/utils/utils.rb
lookbook-1.5.0 lib/lookbook/support/utils/utils.rb
lookbook-1.4.5 lib/lookbook/support/utils/utils.rb
lookbook-1.4.4 lib/lookbook/support/utils/utils.rb
lookbook-1.4.3 lib/lookbook/support/utils/utils.rb
lookbook-1.4.2 lib/lookbook/support/utils/utils.rb
lookbook-1.4.1 lib/lookbook/support/utils/utils.rb
lookbook-1.4.0 lib/lookbook/support/utils/utils.rb