Parent

Printers::Xml::Variable

Attributes

kind[R]
name[R]

Public Class Methods

new(name, value, kind = nil) click to toggle source
# File lib/debugger/printers/xml.rb, line 96
def initialize(name, value, kind = nil)
  @name = name.to_s
  @value = value
  @kind = kind
end

Public Instance Methods

has_children?() click to toggle source
# File lib/debugger/printers/xml.rb, line 102
def has_children?
  if @value.is_a?(Array) || @value.is_a?(Hash)
    !@value.empty?
  else
    !@value.instance_variables.empty? || !@value.class.class_variables.empty?
  end
rescue
  false
end
id() click to toggle source
# File lib/debugger/printers/xml.rb, line 133
def id
  @value.respond_to?(:object_id) ? "%#+x" % @value.object_id : nil
rescue
  nil
end
to_hash() click to toggle source
# File lib/debugger/printers/xml.rb, line 145
def to_hash
  {name: @name, kind: @kind, value: value, type: type, has_children: has_children?, id: id}
end
type() click to toggle source
# File lib/debugger/printers/xml.rb, line 139
def type
  @value.class
rescue
  "Undefined"
end
value() click to toggle source
# File lib/debugger/printers/xml.rb, line 112
def value
  if @value.is_a?(Array) || @value.is_a?(Hash)
    if has_children?
      "#{@value.class} (#{@value.size} element(s))"
    else
      "Empty #{@value.class}"
    end
  else
    value_str = @value.nil? ? 'nil' : @value.to_s
    if !value_str.is_a?(String)
      "ERROR: #{@value.class}.to_s method returns #{value_str.class}. Should return String."
    elsif binary_data?(value_str)
      "[Binary Data]"
    else
      value_str.gsub(/^(")(.*)(")$/, '\2')
    end
  end
rescue => e
  "<raised exception: #{e}>"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.