class BetaBrite::String
This class encapsulates a string and attributes about the string such as color, character set, and also contains special characters.
Constants
- BALL
- BOTTLE
- CAR
- COPYRIGHT
- DISKETTE
- DOWN_ARROW
- FEMALE_SYM
- HANDICAP
- HEART
- INFINITY
- LEFT_ARROW
- MALE_SYM
- MUG
- NOTE
- PACKMAN
- PRINTER
- RETURN_ARROW
- RHINO
- RIGHT_ARROW
- SAIL_BOAT
- SATELLITE_DISH
- SM_DOWN_ARROW
- SM_LEFT_ARROW
- SM_RIGHT_ARROW
- SM_UP_ARROW
- TELEPHONE
- UP_ARROW
Attributes
charset[RW]
color[RW]
string[RW]
Public Class Methods
new(string, opts = {}) { |self| ... }
click to toggle source
# File lib/betabrite/string.rb, line 76 def initialize(string, opts = {}) args = { :color => Color::GREEN, :charset => CharSet::SEVEN_HIGH }.merge opts @string = string @color = args[:color] @charset = args[:charset] yield self if block_given? end
parse(string)
click to toggle source
Break up a string into betabrite strings
# File lib/betabrite/string.rb, line 66 def parse(string) string.split(/#{0x1a.chr}/).select { |s| s.length > 0 }.map { |s| data = /(.)#{0x1c.chr}Z?([^Z]{6}|[^Z])(.*)$/.match(s) new(data[3], :color => data[2], :charset => data[1]) } end
Public Instance Methods
+(other)
click to toggle source
# File lib/betabrite/string.rb, line 86 def +(other) self.to_s + other.to_s end
rgb(rgb_color)
click to toggle source
# File lib/betabrite/string.rb, line 90 def rgb(rgb_color) self.color = "#{rgb_color}" self end
to_s()
click to toggle source
# File lib/betabrite/string.rb, line 95 def to_s "#{0x1a.chr}#{@charset}#{0x1c.chr}" + (@color.length > 1 ? "Z#{@color}" : "#{@color}") + "#{@string}" end
Also aliased as: to_str