Class: JsshDOMNode

Inherits:
JsshObject show all
Defined in:
lib/vapir-firefox/jssh_socket.rb

Instance Attribute Summary

Attributes inherited from JsshObject

#debug_name, #function_result, #jssh_socket, #ref, #type

Instance Method Summary collapse

Methods inherited from JsshObject

#%, #*, #+, #-, #/, #<, #<=, #==, #>, #>=, #[], #[]=, #assign, #assign_expr, #attr, #binary_operator, #call, #define_methods!, #id, #implemented_interfaces, #initialize, #instanceof, #invoke, #method_missing, #object_respond_to?, #object_type, #pass, #respond_to?, #store, #store_rand_named, #store_rand_object_key, #store_rand_prefix, #store_rand_temp, #sub, #to_array, #to_dom, #to_hash, #to_js_array, #to_js_hash, #to_js_hash_safe, #to_json, #to_jssh, #to_ruby_hash, #val, #val_or_object, #val_str

Constructor Details

This class inherits a constructor from JsshObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JsshObject

Instance Method Details

#dump(options = {}) ⇒ Object



1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
# File 'lib/vapir-firefox/jssh_socket.rb', line 1037

def dump(options={})
  options={:recurse => nil, :level => 0}.merge(options)
  next_options=options.merge(:recurse => options[:recurse] && (options[:recurse]-1), :level => options[:level]+1)
  result=(" "*options[:level]*2)+self.inspect+"\n"
  if options[:recurse]==0
    result+=(" "*next_options[:level]*2)+"...\n"
  else 
    self.childNodes.to_array.each do |child|
      result+=child.to_dom.dump(next_options)
    end
  end
  result
end

#inspectObject



1021
1022
1023
# File 'lib/vapir-firefox/jssh_socket.rb', line 1021

def inspect
  "\#<#{self.class.name} #{inspect_stuff.map{|(k,v)| "#{k}=#{v.inspect}"}.join(', ')}>"
end

#inspect_stuffObject



1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
# File 'lib/vapir-firefox/jssh_socket.rb', line 1011

def inspect_stuff
  [:nodeName, :nodeType, :nodeValue, :tagName, :textContent, :id, :name, :value, :type, :className, :hidden].map do |attrn|
    attr=attr(attrn)
    if ['undefined','null'].include?(attr.type)
      nil
    else
      [attrn, attr.val_or_object(:error_on_undefined => false)]
    end
  end.compact
end

#pretty_print(pp) ⇒ Object



1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
# File 'lib/vapir-firefox/jssh_socket.rb', line 1024

def pretty_print(pp)
  pp.object_address_group(self) do
    pp.seplist(inspect_stuff, lambda { pp.text ',' }) do |attr_val|
      pp.breakable ' '
      pp.group(0) do
        pp.text attr_val.first.to_s
        pp.text ': '
        #pp.breakable
        pp.text attr_val.last.inspect
      end
    end
  end
end