Class: ANSI::Chain

### Home Classes Methods

### In Files

- lib/ansi/chain.rb

### Parent

Object

### Methods

- ::new
- #method_missing
- #to_s
- #to_str

### Files

- COPYING.rdoc
- DEMO.rdoc
- HISTORY.rdoc
- README.rdoc

### Class/Module Index

Quicksearch

- ANSI
- ANSI::BBCode
- ANSI::Chain
- ANSI::Code
- ANSI::Columns
- ANSI::Constants
- ANSI::Diff
- ANSI::HexDump
- ANSI::Logger
- ANSI::Mixin
- ANSI::ProgressBar
- ANSI::String
- ANSI::Table
- ANSI::Terminal
- Object
- String

No matching classes.

# ANSI::Chain

ANSI::Chain was inspired by Kazuyoshi Tlacaelel's Isna library.

### Attributes

codes[R]
string[R]

### Public Class Methods

new(string) click to toggle source

    # File lib/ansi/chain.rb, line 10
    def initialize(string)
      @string = string.to_s
      @codes  = []
    end

### Public Instance Methods

method_missing(s, *a, &b) click to toggle source

    # File lib/ansi/chain.rb, line 22
    def method_missing(s, *a, &b)
      if ANSI::CHART.key?(s)
        @codes << s
        self
      else
        super(s, *a, &b)
      end
    end

to_s() click to toggle source

    # File lib/ansi/chain.rb, line 32
    def to_s
      if codes.empty?
        result = @string
      else
        result = Code.ansi(@string, *codes)
        codes.clear
      end
      result
    end

to_str() click to toggle source

    # File lib/ansi/chain.rb, line 43
    def to_str
      to_s
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.