Class: EacRubyUtils::CustomFormat
- Defined in:
- lib/eac_ruby_utils/custom_format.rb
Overview
A formatter like [String.sprintf].
Defined Under Namespace
Classes: String
Constant Summary collapse
- TYPE_PATTERN =
/[a-zA-Z]/.freeze
- SEQUENCE_PATTERN =
/(?<!%)%(#{TYPE_PATTERN})/.freeze
Instance Attribute Summary collapse
-
#mapping ⇒ Object
readonly
Returns the value of attribute mapping.
Instance Method Summary collapse
- #format(string) ⇒ Object
-
#initialize(mapping) ⇒ CustomFormat
constructor
A new instance of CustomFormat.
Constructor Details
#initialize(mapping) ⇒ CustomFormat
Returns a new instance of CustomFormat.
11 12 13 |
# File 'lib/eac_ruby_utils/custom_format.rb', line 11 def initialize(mapping) @mapping = mapping.transform_keys(&:to_sym).freeze end |
Instance Attribute Details
#mapping ⇒ Object (readonly)
Returns the value of attribute mapping.
9 10 11 |
# File 'lib/eac_ruby_utils/custom_format.rb', line 9 def mapping @mapping end |
Instance Method Details
#format(string) ⇒ Object
15 16 17 |
# File 'lib/eac_ruby_utils/custom_format.rb', line 15 def format(string) ::EacRubyUtils::CustomFormat::String.new(self, string) end |