class Zend::Command::Base
Public Instance Methods
api()
click to toggle source
# File lib/zend/command/base.rb, line 2 def api Zend::Auth.api end
is_num?(str)
click to toggle source
# File lib/zend/command/base.rb, line 24 def is_num?(str) begin !!Integer(str) rescue ArgumentError, TypeError false end end
terminal_width()
click to toggle source
# File lib/zend/command/base.rb, line 6 def terminal_width result = unix? ? dynamic_width : 80 (result < 10) ? 80 : result rescue 80 end
truncate(text, length, options = {})
click to toggle source
# File lib/zend/command/base.rb, line 13 def truncate(text, length, options = {}) options[:omission] ||= "..." length_with_room_for_omission = length - options[:omission].length chars = text stop = options[:separator] ? (chars.rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission) : length_with_room_for_omission (chars.length > length ? chars[0...stop] + options[:omission] : text).to_s end
Private Instance Methods
dynamic_width()
click to toggle source
# File lib/zend/command/base.rb, line 38 def dynamic_width @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput) end
dynamic_width_stty()
click to toggle source
# File lib/zend/command/base.rb, line 42 def dynamic_width_stty %x{stty size 2>/dev/null}.split[1].to_i end
dynamic_width_tput()
click to toggle source
# File lib/zend/command/base.rb, line 46 def dynamic_width_tput %x{tput cols 2>/dev/null}.to_i end
unix?()
click to toggle source
# File lib/zend/command/base.rb, line 34 def unix? RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i end