Class: Seedify::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/seedify/logger.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Logger

Returns a new instance of Logger.



15
16
17
# File 'lib/seedify/logger.rb', line 15

def initialize(context)
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



3
4
5
# File 'lib/seedify/logger.rb', line 3

def context
  @context
end

Class Method Details

.max_seed_name_lengthObject



9
10
11
12
13
# File 'lib/seedify/logger.rb', line 9

def self.max_seed_name_length
  @max_seed_name_length ||= Seedify::Storage.seed_list.map do |name|
    seed_name_formatter(name).length
  end.max
end

.seed_name_formatter(name) ⇒ Object



5
6
7
# File 'lib/seedify/logger.rb', line 5

def self.seed_name_formatter(name)
  name.to_s.sub(/Seed$/, '')
end

Instance Method Details

#each(array, message, &block) ⇒ Object



25
26
27
# File 'lib/seedify/logger.rb', line 25

def each(array, message, &block)
  process_items(array, array.length, message, &block)
end

#line(message, &block) ⇒ Object



19
20
21
22
23
# File 'lib/seedify/logger.rb', line 19

def line(message, &block)
  print "#{name} #{formatted_message message}"
  yield if block_given?
  print "\n"
end

#times(count, message, &block) ⇒ Object



29
30
31
# File 'lib/seedify/logger.rb', line 29

def times(count, message, &block)
  process_items(count.times.to_a, count, message, &block)
end