Class: Crowbar::Client::Formatter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/crowbar/client/formatter/base.rb

Overview

Base that provides methods shared between different formatters

Direct Known Subclasses

Array, Hash, Nested

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



26
27
28
# File 'lib/crowbar/client/formatter/base.rb', line 26

def initialize(options = {})
  self.options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



24
25
26
# File 'lib/crowbar/client/formatter/base.rb', line 24

def options
  @options
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/crowbar/client/formatter/base.rb', line 44

def empty?
  false
end

#resultObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/crowbar/client/formatter/base.rb', line 30

def result
  case options[:format].to_sym
  when :table
    process_table
  when :plain
    process_plain
  when :json
    process_json
  else
    raise InvalidFormatError,
      "You requested an invalid format for this resource"
  end
end