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.



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

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

  @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.



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

def date_pattern
  @date_pattern
end

#modifierObject (readonly)

Returns the value of attribute modifier.



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

def modifier
  @modifier
end

#patternObject

Returns the value of attribute pattern.



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

def pattern
  @pattern
end

Instance Method Details

#modify(key, &block) ⇒ Object



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

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