Module: Eve::API::Response::Inspection
- Included in:
- Eve::API::Response, Rowset
- Defined in:
- lib/eve/api/response/inspection.rb
Instance Method Summary collapse
- #inspect ⇒ Object
- #inspected_elements ⇒ Object
- #inspected_instance_variables ⇒ Object
- #inspected_name ⇒ Object
- #inspected_rowsets ⇒ Object
- #protected_instance_variables ⇒ Object
Instance Method Details
#inspect ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/eve/api/response/inspection.rb', line 52 def inspect r = "#<#{inspected_name}" r.concat " #{inspected_instance_variables}" if !inspected_instance_variables.nil? r.concat ">" r.concat "#{inspected_elements}" if !inspected_elements.nil? return r end |
#inspected_elements ⇒ Object
20 21 22 23 |
# File 'lib/eve/api/response/inspection.rb', line 20 def inspected_elements return nil unless respond_to?(:empty?) && !empty? "[#{self.collect { |i| i.inspect }.join(", ")}]" end |
#inspected_instance_variables ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/eve/api/response/inspection.rb', line 25 def inspected_instance_variables return nil if (ivars = instance_variables - protected_instance_variables).empty? ivars.sort! do |a, b| original = a <=> b a = instance_variable_get(a) b = instance_variable_get(b) a_rowset = a.kind_of?(Rowset) b_rowset = b.kind_of?(Rowset) if a_rowset && b_rowset then a.name <=> b.name elsif a_rowset && !b_rowset then 1 elsif !a_rowset && b_rowset then -1 else original end end "#{ivars.map do |ivar| v = instance_variable_get(ivar) if v.kind_of?(Rowset) v.inspect else "#{ivar[1..-1]}=>#{instance_variable_get(ivar).inspect}" end end.join(" ")}" end |
#inspected_name ⇒ Object
11 12 13 |
# File 'lib/eve/api/response/inspection.rb', line 11 def inspected_name respond_to?(:name) ? self.name : "(Response)" end |
#inspected_rowsets ⇒ Object
15 16 17 18 |
# File 'lib/eve/api/response/inspection.rb', line 15 def inspected_rowsets return nil unless respond_to?(:rowsets) && !rowsets.empty? "[#{rowsets.collect { |r| r.inspect }.join(", ")}]" end |
#protected_instance_variables ⇒ Object
5 6 7 8 9 |
# File 'lib/eve/api/response/inspection.rb', line 5 def protected_instance_variables (respond_to?(:content) && !content.blank? ? [] : ["@content"]) + #(respond_to?(:rowsets) && !rowsets.empty? ? rowsets.collect { |r| "@#{r.name}" } : []) + [:@rowsets, :@options, :@xml, :@columns, :@row, :@name] end |