Class: MOTD
- Inherits:
-
Object
- Object
- MOTD
- Defined in:
- lib/panda_motd/motd.rb
Instance Attribute Summary collapse
-
#components ⇒ Object
readonly
Returns the value of attribute components.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(config_path = nil, process = true) ⇒ MOTD
constructor
A new instance of MOTD.
- #to_s ⇒ Object
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
#components ⇒ Object (readonly)
Returns the value of attribute components.
4 5 6 |
# File 'lib/panda_motd/motd.rb', line 4 def components @components end |
#config ⇒ Object (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_s ⇒ Object
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 |