Class: Gloo::Objs::Banner

Inherits:
GlooLang::Core::Obj
  • Object
show all
Defined in:
lib/gloo/objs/cli/banner.rb

Constant Summary collapse

KEYWORD =
'banner'.freeze
KEYWORD_SHORT =
'ban'.freeze
TEXT =
'text'.freeze
STYLE =
'style'.freeze
COLOR =
'color'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.messagesObject

Get a list of message names that this object receives.



91
92
93
# File 'lib/gloo/objs/cli/banner.rb', line 91

def self.messages
  return super + %w[show]
end

.short_typenameObject

The short name of the object type.



29
30
31
# File 'lib/gloo/objs/cli/banner.rb', line 29

def self.short_typename
  return KEYWORD_SHORT
end

.typenameObject

The name of the object type.



22
23
24
# File 'lib/gloo/objs/cli/banner.rb', line 22

def self.typename
  return KEYWORD
end

Instance Method Details

#add_children_on_create?Boolean

Does this object have children to add when an object is created in interactive mode? This does not apply during obj load, etc.

Returns:

  • (Boolean)


70
71
72
# File 'lib/gloo/objs/cli/banner.rb', line 70

def add_children_on_create?
  return true
end

#add_default_childrenObject

Add children to this object. This is used by containers to add children needed for default configurations.



77
78
79
80
81
82
# File 'lib/gloo/objs/cli/banner.rb', line 77

def add_default_children
  fac = @engine.factory
  fac.create_string TEXT, '', self
  fac.create_string STYLE, '', self
  fac.create_string COLOR, '', self
end

#color_valueObject

Get the banner color from the child object.



56
57
58
59
60
61
# File 'lib/gloo/objs/cli/banner.rb', line 56

def color_value
  o = find_child COLOR
  return '' unless o

  return o.value
end

#msg_showObject

Show the banner bar



98
99
100
101
102
103
104
# File 'lib/gloo/objs/cli/banner.rb', line 98

def msg_show
  font = TTY::Font.new self.style_value
  t = font.write( self.text_value )
  pastel = ::Pastel.new
  c = self.color_value.split( ' ' ).map( &:to_sym )
  puts pastel.decorate( t, *c )
end

#style_valueObject

Get the banner style from the child object.



46
47
48
49
50
51
# File 'lib/gloo/objs/cli/banner.rb', line 46

def style_value
  o = find_child STYLE
  return '' unless o

  return o.value
end

#text_valueObject

Get the banner text from the child object.



36
37
38
39
40
41
# File 'lib/gloo/objs/cli/banner.rb', line 36

def text_value
  o = find_child TEXT
  return '' unless o

  return o.value
end