Class: Component

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(motd, name) ⇒ Component

Returns a new instance of Component.



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

def initialize(motd, name)
  @name = name
  @motd = motd
  @config = motd.config.component_config(@name)
  @errors = []
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

#errorsObject (readonly)

Returns the value of attribute errors.



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

def errors
  @errors
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#resultsObject (readonly)

Returns the value of attribute results.



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

def results
  @results
end

Instance Method Details

#lines_afterObject

The number of lines to print after the component in the context of the entire MOTD. 1 by default, if not configured.



32
33
34
# File 'lib/panda_motd/component.rb', line 32

def lines_after
  @motd.config.component_config(@name)["lines_after"] || 1
end

#lines_beforeObject

The number of lines to print before the component in the context of the entire MOTD. 1 by default, if not configured.



26
27
28
# File 'lib/panda_motd/component.rb', line 26

def lines_before
  @motd.config.component_config(@name)["lines_before"] || 1
end

#processObject

Evaluates the component so that it has some meaningful output when it comes time to print the MOTD.

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/panda_motd/component.rb', line 15

def process
  raise NotImplementedError
end

#to_sObject

Gives the output of a component as a string.

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/panda_motd/component.rb', line 20

def to_s
  raise NotImplementedError
end