Class: RBText::Ftext
- Inherits:
-
Object
- Object
- RBText::Ftext
- Defined in:
- lib/rbtext/ftext.rb
Instance Method Summary collapse
-
#initialize(str) ⇒ Ftext
constructor
A new instance of Ftext.
- #normal_text ⇒ Object
- #original_text ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(str) ⇒ Ftext
Returns a new instance of Ftext.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rbtext/ftext.rb', line 3 def initialize(str) @original_text = str @text = "" str = str.split("_") for x in str do if x[0] == "." && x[x.length-1] == "." && x.split(":").length == 2 x = x.downcase.gsub(".", "").gsub("-","_") x = x.split(":") if x[0] == "cf" || x[0] == "c" @text << RBText::Colors.color(x[1].to_sym) elsif x[0] == "cb" @text << RBText::Colors.color(x[1].to_sym, type: :bg) elsif x[0] == "f" if x[1] == "reset" @text << RBText::Formatting.reset elsif x[1] == "bold" @text << RBText::Formatting.bold elsif x[1] == "faint" @text << RBText::Formatting.faint elsif x[1] == "italic" @text << RBText::Formatting.italic elsif x[1] == "underline" @text << RBText::Formatting.underline end end else @text << x end end end |
Instance Method Details
#normal_text ⇒ Object
41 42 43 |
# File 'lib/rbtext/ftext.rb', line 41 def normal_text @original_text.gsub(/\_\.([a-z]){1,2}\:([a-z\-])+\.\_/, "") end |
#original_text ⇒ Object
45 46 47 |
# File 'lib/rbtext/ftext.rb', line 45 def original_text @original_text end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/rbtext/ftext.rb', line 37 def to_s @text end |