Class: VkillGemsMethods::STD::Display

Inherits:
Object
  • Object
show all
Defined in:
lib/vkill_gems_methods/std.rb

Constant Summary collapse

ANSI_COLOR =
%w(black red green yellow blue magenta cyan white)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*options, &block) ⇒ Display

Returns a new instance of Display.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vkill_gems_methods/std.rb', line 11

def initialize(*options, &block)
  options = options.extract_options!
  header = options.delete(:header) || "info"
  text = options.delete(:text) || ""
  color = options.delete(:color) || 'green'
  rjust_integer = options.delete(:rjust_integer) || 12

  @header = header.to_s
  @text = text.to_s
  @color = ANSI_COLOR.include?(color.to_s) ? color.to_s : 'green'
  @rjust_integer = rjust_integer.to_i

  @c = Term::ANSIColor
  @output = ""

  @output << eval("#{@c}.#{@color}")
  @output << @header.capitalize.rjust(@rjust_integer)
  @output << @c.clear
  @output << "  #{ @text }"
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



9
10
11
# File 'lib/vkill_gems_methods/std.rb', line 9

def color
  @color
end

#headerObject (readonly)

Returns the value of attribute header.



9
10
11
# File 'lib/vkill_gems_methods/std.rb', line 9

def header
  @header
end

#outputObject (readonly)

Returns the value of attribute output.



9
10
11
# File 'lib/vkill_gems_methods/std.rb', line 9

def output
  @output
end

#rjust_integerObject (readonly)

Returns the value of attribute rjust_integer.



9
10
11
# File 'lib/vkill_gems_methods/std.rb', line 9

def rjust_integer
  @rjust_integer
end

#textObject (readonly)

Returns the value of attribute text.



9
10
11
# File 'lib/vkill_gems_methods/std.rb', line 9

def text
  @text
end