Class: Yell::Formatter::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/yell/formatter.rb

Overview

Builder class to allow setters that won’t be accessible once transferred to the Formatter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern = nil, date_pattern = nil, &block) ⇒ Builder

Returns a new instance of Builder.



159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/yell/formatter.rb', line 159

def initialize( pattern = nil, date_pattern = nil, &block )
  @modifier = Modifier.new

  @pattern = case pattern
  when false then Yell::NoFormat
  when nil then Yell::DefaultFormat
  else pattern
  end.dup

  @pattern << "\n" unless @pattern[-1] == ?\n # add newline if not present
  @date_pattern = date_pattern || :iso8601

  block.call(self) if block
end

Instance Attribute Details

#date_patternObject

Returns the value of attribute date_pattern.



156
157
158
# File 'lib/yell/formatter.rb', line 156

def date_pattern
  @date_pattern
end

#modifierObject (readonly)

Returns the value of attribute modifier.



157
158
159
# File 'lib/yell/formatter.rb', line 157

def modifier
  @modifier
end

#patternObject

Returns the value of attribute pattern.



156
157
158
# File 'lib/yell/formatter.rb', line 156

def pattern
  @pattern
end

Instance Method Details

#modify(key, &block) ⇒ Object



174
175
176
# File 'lib/yell/formatter.rb', line 174

def modify( key, &block )
  modifier.set(key, &block)
end