Sha256: 3c44efd67000483792b7f36093669a191ec0548dc2ae110b1eb8a05aa3c16b84

Contents?: true

Size: 629 Bytes

Versions: 2

Compression:

Stored size: 629 Bytes

Contents

module Hexdump
  #
  # @api private
  #
  # @since 1.0.0
  #
  class FormatString

    #
    # Initializes the format string.
    #
    # @param [String] fmt
    #   The format string.
    #
    def initialize(fmt)
      @fmt = fmt
    end

    #
    # Formats the given value.
    #
    # @param [Integer, Float] value
    #   The given value.
    #
    # @return [String]
    #   The formatted value.
    #
    def %(value)
      sprintf(@fmt,value)
    end

    #
    # Converts the format string back into a String.
    #
    # @return [String]
    #   The raw format string.
    #
    def to_s
      @fmt
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hexdump-1.0.1 lib/hexdump/format_string.rb
hexdump-1.0.0 lib/hexdump/format_string.rb