Class: BetaBrite::String

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

Overview

This class encapsulates a string and attributes about the string such as color, character set, and also contains special characters.

Defined Under Namespace

Classes: CharSet, Color

Constant Summary collapse

LEFT_ARROW =
0xc6.chr
RIGHT_ARROW =
0xc6.chr
PACKMAN =
0xc8.chr
SAIL_BOAT =
0xc9.chr
BALL =
0xca.chr
TELEPHONE =
0xcb.chr
HEART =
0xcc.chr
CAR =
0xcd.chr
HANDICAP =
0xce.chr
RHINO =
0xcf.chr
MUG =
0xd0.chr
SATELLITE_DISH =
0xd1.chr
0xd2.chr
MALE_SYM =
0xd3.chr
FEMALE_SYM =
0xd4.chr
BOTTLE =
0xd5.chr
DISKETTE =
0xd6.chr
PRINTER =
0xd7.chr
NOTE =
0xd8.chr
INFINITY =
0xd9.chr

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, opts = {}) ⇒ String

Returns a new instance of String.



57
58
59
60
61
62
63
64
# File 'lib/string.rb', line 57

def initialize(string, opts = {})
  args = {  :color    => Color::GREEN,
            :charset  => CharSet::SEVEN_HIGH
         }.merge opts
  @string   = string
  @color    = args[:color]
  @charset  = args[:charset]
end

Instance Attribute Details

#charsetObject

Returns the value of attribute charset.



55
56
57
# File 'lib/string.rb', line 55

def charset
  @charset
end

#colorObject

Returns the value of attribute color.



55
56
57
# File 'lib/string.rb', line 55

def color
  @color
end

#stringObject

Returns the value of attribute string.



55
56
57
# File 'lib/string.rb', line 55

def string
  @string
end

Instance Method Details

#to_sObject



66
67
68
# File 'lib/string.rb', line 66

def to_s
  "#{0x1a.chr}#{@charset}#{0x1c.chr}#{@color}#{@string}"
end