Module: Choria::Colt::CLI::Formatter::FormattedResult

Defined in:
lib/choria/colt/cli/formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pastelObject

Returns the value of attribute pastel.



44
45
46
# File 'lib/choria/colt/cli/formatter.rb', line 44

def pastel
  @pastel
end

Instance Method Details

#contentObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/choria/colt/cli/formatter.rb', line 54

def content
  case statuscode
  when 0
    # 0 	OK
    format_success
  when 1
    # 1 	OK, failed. All the data parsed ok, we have a action matching the request but the requested action could not be completed. 	RPCAborted
    format_error
  else
    # 2 	Unknown action 	UnknownRPCAction
    # 3 	Missing data 	MissingRPCData
    # 4 	Invalid data 	InvalidRPCData
    # 5 	Other error
    format_rpc_error
  end
end

#hostObject



46
47
48
49
50
51
52
# File 'lib/choria/colt/cli/formatter.rb', line 46

def host
  if statuscode.zero?
    format_host pastel.bright_green('').to_s
  else
    format_host pastel.bright_red('').to_s
  end
end

#to_sObject



71
72
73
74
75
76
# File 'lib/choria/colt/cli/formatter.rb', line 71

def to_s
  [
    host,
    content,
  ].join("\n")
end