Class: JQuery::Parser

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

Constant Summary collapse

@@parsed =
Hpricot::XML(File.read(PATH))

Class Method Summary collapse

Class Method Details

.category_listObject



62
63
64
# File 'lib/jquery-cheat.rb', line 62

def self.category_list
  @@parsed.search("[@cat]").map {|x| x.get_attribute("cat")}.uniq
end

.get_methods_by_hash(options = {}) ⇒ Object

The options hash supports the following options

name

search for methods matching the name passed

substring

to be used with :name. If :substring is true, all functions containing the substring passed in :name will be returned (defaults to false).

module

search for methods in :module

recursive

to be used with :module. If :recursive is true, all functions in :module, or its child modules will be returned (defaults to false)

like

search for methods whose descriptions include any strings included in the Array :like

params

search for methods whose parameters include all of the strings include in the Array :params



52
53
54
55
56
57
58
59
60
# File 'lib/jquery-cheat.rb', line 52

def self.get_methods_by_hash options = {}
  filters = "method"
  filters += "[@name#{ '*' if options[:substring] }='#{options[:name]}']" if options[:name]
  filters += "[@cat#{ '*' if options[:recursive] }='#{options[:module]}']" if options[:module]
  methods = @@parsed.search(filters)
  methods.reject! {|m| options[:like].any? {|t| m.search("> desc").inner_text !~ /#{t}/i} } if options[:like]
  methods.reject! {|m| options[:params].any? {|p| m.search("params[@name=#{p}]").length == 0 } } if options[:params]
  methods
end