Class: MOTD

Inherits:
Object
  • Object
show all
Defined in:
lib/panda_motd/motd.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path = nil, process = true) ⇒ MOTD

Returns a new instance of MOTD.



6
7
8
9
10
# File 'lib/panda_motd/motd.rb', line 6

def initialize(config_path = nil, process = true)
  @config = config_path ? Config.new(config_path) : Config.new
  @components = @config.components_enabled.map { |ce| ce.new(self) }
  @components.each(&:process) if process
end

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.



4
5
6
# File 'lib/panda_motd/motd.rb', line 4

def components
  @components
end

#configObject (readonly)

Returns the value of attribute config.



4
5
6
# File 'lib/panda_motd/motd.rb', line 4

def config
  @config
end

Instance Method Details

#to_sObject



12
13
14
15
16
17
18
19
20
# File 'lib/panda_motd/motd.rb', line 12

def to_s
  @components.map do |c|
    if c.errors.any?
      c.errors.map(&:to_s).join("\n")
    else
      c.to_s
    end
  end.join("\n\n")
end