Module: I18n::Message::Formatted
- Defined in:
- lib/i18n/message/formatted.rb
Overview
Encapsulates the pattern of wrapping a string with a format string.
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
21 22 23 |
# File 'lib/i18n/message/formatted.rb', line 21 def format @format end |
Class Method Details
.included(base) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/i18n/message/formatted.rb', line 7 def self.included(base) base.class_eval do class << self def format_class # FIXME use inheritable_attribute_accessor @format_class ||= Format end def format_class=(format_class) @format_class = format_class end end end end |
Instance Method Details
#initialize(subject = nil, options = {}) ⇒ Object
23 24 25 26 |
# File 'lib/i18n/message/formatted.rb', line 23 def initialize(subject = nil, = {}) @format = .delete(:format) super end |
#to_s(variant = nil) ⇒ Object
28 29 30 |
# File 'lib/i18n/message/formatted.rb', line 28 def to_s(variant = nil) formatted(super(variant), variant || :default) end |