Class: Gloo::Objs::Banner

Inherits:
Core::Obj 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

Constants inherited from Core::Baseo

Core::Baseo::NOT_IMPLEMENTED_ERR

Instance Attribute Summary

Attributes inherited from Core::Obj

#children, #parent, #value

Attributes inherited from Core::Baseo

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Core::Obj

#add_child, can_create?, #can_receive_message?, #child_count, #contains_child?, #delete_children, #dispatch, #display_value, #find_add_child, #find_child, help, inherited, #initialize, #msg_reload, #msg_unload, #multiline_value?, #pn, #remove_child, #root?, #send_message, #set_parent, #set_value, #type_display, #value_display, #value_is_array?, #value_is_blank?, #value_string?

Methods inherited from Core::Baseo

#initialize, #type_display

Constructor Details

This class inherits a constructor from Gloo::Core::Obj

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

.show_banner(text, style, color) ⇒ Object

Show the banner bar. text - the text of the banner style - the style of the banner color - the color of the banner



108
109
110
111
112
113
114
# File 'lib/gloo/objs/cli/banner.rb', line 108

def self.show_banner( text, style, color )
  font = TTY::Font.new style
  t = font.write( text )
  pastel = ::Pastel.new
  c = color.split( ' ' ).map( &:to_sym )
  puts pastel.decorate( t, *c )
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:



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
# File 'lib/gloo/objs/cli/banner.rb', line 98

def msg_show
  Banner.show_banner( self.text_value, self.style_value, self.color_value )
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