Module: Fog::Formatador
- Defined in:
 - lib/fog/formatador.rb
 
Overview
Fog::Formatador
Constant Summary collapse
- PARSE_REGEX =
 ::Formatador::PARSE_REGEX
- STYLES =
 ::Formatador::STYLES
- INDENT_REGEX =
 ::Formatador::INDENT_REGEX
Class Method Summary collapse
- .attribute_string(object) ⇒ Object
 - .display_compact_table(hashes, keys = nil, &block) ⇒ Object
 - .display_line(data) ⇒ Object
 - .display_lines(data) ⇒ Object
 - .display_table(hashes, keys = nil, &block) ⇒ Object
 - .format(object, opts = { include_nested: true }) ⇒ Object
 - .formatador ⇒ Object
 - .indent(&block) ⇒ Object
 - .indentation ⇒ Object
 - .init_string(object) ⇒ Object
 - .inspect_object(object) ⇒ Object
 - .nested_objects_string(object) ⇒ Object
 - .object_attributes(object) ⇒ Object
 - .object_string(object, opts) ⇒ Object
 - .redisplay_progressbar(current, total, options = {}) ⇒ Object
 
Class Method Details
.attribute_string(object) ⇒ Object
      56 57 58 59 60 61 62 63 64  | 
    
      # File 'lib/fog/formatador.rb', line 56 def self.attribute_string(object) return "" unless object.class.respond_to?(:attributes) if object.class.attributes.empty? "" else "#{indentation}#{object_attributes(object)}\n" end end  | 
  
.display_compact_table(hashes, keys = nil, &block) ⇒ Object
      26 27 28  | 
    
      # File 'lib/fog/formatador.rb', line 26 def self.display_compact_table(hashes, keys = nil, &block) ::Formatador.display_compact_table(hashes, keys, &block) end  | 
  
.display_line(data) ⇒ Object
      18 19 20  | 
    
      # File 'lib/fog/formatador.rb', line 18 def self.display_line(data) ::Formatador.display_line(data) end  | 
  
.display_lines(data) ⇒ Object
      22 23 24  | 
    
      # File 'lib/fog/formatador.rb', line 22 def self.display_lines(data) ::Formatador.display_lines(data) end  | 
  
.display_table(hashes, keys = nil, &block) ⇒ Object
      30 31 32  | 
    
      # File 'lib/fog/formatador.rb', line 30 def self.display_table(hashes, keys = nil, &block) ::Formatador.display_table(hashes, keys, &block) end  | 
  
.format(object, opts = { include_nested: true }) ⇒ Object
      12 13 14 15 16  | 
    
      # File 'lib/fog/formatador.rb', line 12 def self.format(object, opts = { include_nested: true }) string = +init_string(object) indent { string << object_string(object, opts) } string << "#{indentation}>" end  | 
  
.formatador ⇒ Object
      8 9 10  | 
    
      # File 'lib/fog/formatador.rb', line 8 def self.formatador Thread.current[:formatador] ||= ::Formatador.new end  | 
  
.indent(&block) ⇒ Object
      38 39 40  | 
    
      # File 'lib/fog/formatador.rb', line 38 def self.indent(&block) formatador.indent(&block) end  | 
  
.indentation ⇒ Object
      42 43 44  | 
    
      # File 'lib/fog/formatador.rb', line 42 def self.indentation formatador.indentation end  | 
  
.init_string(object) ⇒ Object
      46 47 48  | 
    
      # File 'lib/fog/formatador.rb', line 46 def self.init_string(object) "#{indentation}<#{object.class.name}\n" end  | 
  
.inspect_object(object) ⇒ Object
      83 84 85 86 87  | 
    
      # File 'lib/fog/formatador.rb', line 83 def self.inspect_object(object) return "" unless object.is_a?(Enumerable) object.map { |o| indentation + o.inspect }.join(", \n#{indentation}") end  | 
  
.nested_objects_string(object) ⇒ Object
      66 67 68 69 70 71 72 73 74  | 
    
      # File 'lib/fog/formatador.rb', line 66 def self.nested_objects_string(object) nested = "" return nested if object.respond_to?(:empty) and object.empty? return nested unless object.is_a?(Enumerable) nested = +"#{indentation}[\n" indent { nested << indentation + inspect_object(object) } nested << "#{indentation}\n#{indentation}]\n" end  | 
  
.object_attributes(object) ⇒ Object
      76 77 78 79 80 81  | 
    
      # File 'lib/fog/formatador.rb', line 76 def self.object_attributes(object) attrs = object.class.attributes.map do |attr| "#{attr}=#{object.send(attr).inspect}" end attrs.join(",\n#{indentation}") end  | 
  
.object_string(object, opts) ⇒ Object
      50 51 52 53 54  | 
    
      # File 'lib/fog/formatador.rb', line 50 def self.object_string(object, opts) string = +attribute_string(object).to_s string << nested_objects_string(object).to_s if opts[:include_nested] string end  | 
  
.redisplay_progressbar(current, total, options = {}) ⇒ Object
      34 35 36  | 
    
      # File 'lib/fog/formatador.rb', line 34 def self.(current, total, = {}) ::Formatador.(current, total, ) end  |