Sha256: 4e84e98e85b65d52d384c5262e599619e15d4e1732f4ff86388e9abb18dd6660

Contents?: true

Size: 657 Bytes

Versions: 1

Compression:

Stored size: 657 Bytes

Contents

# frozen_string_literal: true

module TmuxERBParser
  module Helpers
    module FormatHelper
      module_function

      def format_and(*args)
        return args.first if args.length < 2

        args.inject { |result, val| format_cond('&&', result, val) }
      end

      def format_or(*args)
        return args.first if args.length < 2

        args.inject { |result, val| format_cond('||', result, val) }
      end

      def format_cond(operator, arg1, arg2)
        "\#{#{operator}:#{arg1},#{arg2}}"
      end

      def format_if(cond, true_value, false_value = nil)
        "\#{?#{cond},#{true_value},#{false_value}}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tmux-erb-parser-0.3.0 lib/tmux-erb-parser/helpers/format_helper.rb