Module: Ripl::Rocket

Defined in:
lib/ripl/rocket.rb

Defined Under Namespace

Modules: Shell

Constant Summary collapse

VERSION =
'0.1.1'
TPUT =
{
  :sc   => `tput sc`,
  :rc   => `tput rc`,
  :cuu1 => `tput cuu1`,
  :cuf1 => `tput cuf1`,
}
COLORS =
{
  :nothing      => '0;0',
  :black        => '0;30',
  :red          => '0;31',
  :green        => '0;32',
  :brown        => '0;33',
  :blue         => '0;34',
  :purple       => '0;35',
  :cyan         => '0;36',
  :light_gray   => '0;37',
  :dark_gray    => '1;30',
  :light_red    => '1;31',
  :light_green  => '1;32',
  :yellow       => '1;33',
  :light_blue   => '1;34',
  :light_purple => '1;35',
  :light_cyan   => '1;36',
  :white        => '1;37',
}

Class Method Summary collapse

Class Method Details

.get_height(data) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/ripl/rocket.rb', line 40

def get_height(data)
  lines      = data.to_s.count("\n")
  long_lines = data.to_s.split("\n").inject(0){ |sum, line|
    sum + (line.display_size / `tput cols`.to_i)
  }
  lines + long_lines
end

.output_heightObject



53
54
55
# File 'lib/ripl/rocket.rb', line 53

def output_height
  1 + ( @height_counter == [0] ? 0 : @height_counter.reduce(:+) || 0 )
end

.reset_output_heightObject



36
37
38
# File 'lib/ripl/rocket.rb', line 36

def reset_output_height
  @height_counter = []
end

.track_output_height(data) ⇒ Object



48
49
50
51
# File 'lib/ripl/rocket.rb', line 48

def track_output_height(data)
  @height_counter ||= []
  @height_counter << get_height(data)
end