Class: Puddle::Resources::ShowAccount

Inherits:
Object
  • Object
show all
Defined in:
lib/puddle/resources/show_account.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_adapter, options = {}) ⇒ ShowAccount

Returns a new instance of ShowAccount.



6
7
8
9
# File 'lib/puddle/resources/show_account.rb', line 6

def initialize(http_adapter, options = {})
  @adapter = http_adapter
  @options = options
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



4
5
6
# File 'lib/puddle/resources/show_account.rb', line 4

def adapter
  @adapter
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/puddle/resources/show_account.rb', line 4

def options
  @options
end

Instance Method Details

#cli_format(results) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/puddle/resources/show_account.rb', line 18

def cli_format(results)
  results = results['account']

  data = ''
  data << sprintf("droplet limit:  %-s\n", results['droplet_limit'])
  data << sprintf("email:          %-s\n", results['email'])
  data << sprintf("uuid:           %-s\n", results['uuid'])
  data << sprintf("email verified: %-s\n", results['email_verified'])
  data
end

#executeObject



11
12
13
14
15
16
# File 'lib/puddle/resources/show_account.rb', line 11

def execute
  results = adapter.api(:get, 'account', options)
  return results if options['format'] == 'json'

  cli_format(results)
end