Class: JQuery::Methods

Inherits:
Array
  • Object
show all
Defined in:
lib/jquery-cheat.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Array

#to_jquery_methods

Constructor Details

#initialize(els) ⇒ Methods

Returns a new instance of Methods.



70
71
72
73
74
75
76
# File 'lib/jquery-cheat.rb', line 70

def initialize els
  if(els.is_a?(Hash))
    push(*JQuery::Parser.get_methods_by_hash(els).to_jquery_methods)
  else
    push(*els.to_jquery_methods)
  end      
end

Class Method Details

.get_methods(options = {}) ⇒ Object



78
79
80
# File 'lib/jquery-cheat.rb', line 78

def self.get_methods options = {}
  JQuery::Parser.get_methods_by_hash(options)
end

.with_name_and_params(name, *params) ⇒ Object



82
83
84
# File 'lib/jquery-cheat.rb', line 82

def self.with_name_and_params name, *params
  new(@@parsed.search("method[@name='#{name}']").reject{|m| params.any? {|p| m.search("params[@name=#{p}]").length == 0 } })
end

Instance Method Details

#named_listObject



86
87
88
89
# File 'lib/jquery-cheat.rb', line 86

def named_list
  list = inject([]) {|s,m| s.push(m.signature) }
  list.empty? ? ["No items found"] : list
end