Class: Imba::Movie

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Colors
Defined in:
lib/imba/movie.rb

Instance Method Summary collapse

Methods included from Colors

#colorize

Instance Method Details

#to_sObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/imba/movie.rb', line 11

def to_s
  terminal_width = `tput cols`
  column = terminal_width.to_i / 2

  ''.tap do |s|
    s << "#{sprintf('%-9s', uniq_id)} #{green(name)}".ljust(column)
    s << ' ' + magenta("(#{year})")
    s << ' ' + red("#{rating}/10")
    s << ' ' + yellow(genres)
    s.rjust(column)
  end
end