Class: Zend::Command::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/zend/command/base.rb

Direct Known Subclasses

Ticket::Description, Ticket::List, Ticket::Show

Instance Method Summary collapse

Instance Method Details

#apiObject



2
3
4
# File 'lib/zend/command/base.rb', line 2

def api
  Zend::Auth.api
end

#is_num?(str) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
# File 'lib/zend/command/base.rb', line 24

def is_num?(str)
  begin
    !!Integer(str)
  rescue ArgumentError, TypeError
    false
  end
end

#terminal_widthObject



6
7
8
9
10
11
# 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 = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# 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