Class: Hexdump::FormatString Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hexdump/format_string.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0

Instance Method Summary collapse

Constructor Details

#initialize(fmt) ⇒ FormatString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the format string.

Parameters:

  • fmt (String)

    The format string.

Since:

  • 1.0.0



15
16
17
# File 'lib/hexdump/format_string.rb', line 15

def initialize(fmt)
  @fmt = fmt
end

Instance Method Details

#%(value) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Formats the given value.

Parameters:

  • value (Integer, Float)

    The given value.

Returns:

  • (String)

    The formatted value.

Since:

  • 1.0.0



28
29
30
# File 'lib/hexdump/format_string.rb', line 28

def %(value)
  sprintf(@fmt,value)
end

#to_sString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Converts the format string back into a String.

Returns:

  • (String)

    The raw format string.

Since:

  • 1.0.0



38
39
40
# File 'lib/hexdump/format_string.rb', line 38

def to_s
  @fmt
end