Method: GroupDocs::Api::Entity#inspect

Defined in:
lib/groupdocs/api/entity.rb

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Inspects object using accessors instead of instance variables values.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/groupdocs/api/entity.rb', line 73

def inspect
  not_nil_variables = instance_variables.select do |variable|
    !send(variable_to_accessor(variable)).nil?
  end

  variables = not_nil_variables.map  do |variable|
    accessor = variable_to_accessor(variable)
    value = send(accessor)
    value = case value
            when Symbol then ":#{value}"
            when String then "\"#{value}\""
            else value
            end
    "@#{accessor}=#{value}"
  end

  inspected = self.to_s
  unless variables.empty?
    inspected.gsub!(/>$/, '')
    inspected << " #{variables.join(', ')}"
    inspected << ?>
  end

  inspected
end