Class: ModelFormatting::FormattedPart

Inherits:
Part
  • Object
show all
Defined in:
lib/model_formatting.rb

Instance Attribute Summary collapse

Attributes inherited from Part

#format

Instance Method Summary collapse

Methods inherited from Part

#<<, #==, #compact!, #inspect, #simple_string

Constructor Details

#initialize(format, options = {}, *args) ⇒ FormattedPart

Returns a new instance of FormattedPart.



62
63
64
65
# File 'lib/model_formatting.rb', line 62

def initialize(format, options = {}, *args)
  @options = options || {}
  super(format, *args)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



60
61
62
# File 'lib/model_formatting.rb', line 60

def options
  @options
end

Instance Method Details

#formatted_stringObject



67
68
69
70
71
72
73
# File 'lib/model_formatting.rb', line 67

def formatted_string
  @formatted_string ||= begin
    str = simple_string
    str = @options[:before].call(@format, str, @options) if @options[:before]
    str
  end
end