Class: HighLine::Statement

Inherits:
Object show all
Defined in:
lib/highline/statement.rb

Overview

This class handles proper formatting based on a HighLine context, applying wrapping, pagination, indentation and color rendering when necessary. It’s used by #render_statement

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, highline) ⇒ Statement

It needs the input String and the HighLine context

Parameters:



28
29
30
31
32
# File 'lib/highline/statement.rb', line 28

def initialize(source, highline)
  @highline = highline
  @source   = source
  @template_string = stringfy(source)
end

Instance Attribute Details

#highlineHighLine (readonly)

The HighLine context

Returns:



19
20
21
# File 'lib/highline/statement.rb', line 19

def highline
  @highline
end

#sourceObject (readonly)

The source object to be stringfied and formatted.



15
16
17
# File 'lib/highline/statement.rb', line 15

def source
  @source
end

#template_stringString (readonly)

The stringfied source object

Returns:



23
24
25
# File 'lib/highline/statement.rb', line 23

def template_string
  @template_string
end

Class Method Details

.const_missing(constant) ⇒ Object



48
49
50
# File 'lib/highline/statement.rb', line 48

def self.const_missing(constant)
  HighLine.const_get(constant)
end

Instance Method Details

#statementString

Returns the formated statement. Applies wrapping, pagination, indentation and color rendering based on HighLine instance settings.

Returns:

  • (String)

    formated statement



38
39
40
# File 'lib/highline/statement.rb', line 38

def statement
  @statement ||= format_statement
end

#to_sString

Returns the formated statement. Applies wrapping, pagination, indentation and color rendering based on HighLine instance settings. Delegates to #statement

Returns:

  • (String)

    formated statement



44
45
46
# File 'lib/highline/statement.rb', line 44

def to_s
  statement
end