Class: JQuery::Parser
- Inherits:
-
Object
- Object
- JQuery::Parser
- Defined in:
- lib/jquery-cheat.rb
Constant Summary collapse
- @@parsed =
Hpricot::XML(File.read(PATH))
Class Method Summary collapse
- .category_list ⇒ Object
-
.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.
- search for methods matching the name passed
- The options hash supports the following options
Class Method Details
.category_list ⇒ Object
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 = {} filters = "method" filters += "[@name#{ '*' if [:substring] }='#{[:name]}']" if [:name] filters += "[@cat#{ '*' if [:recursive] }='#{[:module]}']" if [:module] methods = @@parsed.search(filters) methods.reject! {|m| [:like].any? {|t| m.search("> desc").inner_text !~ /#{t}/i} } if [:like] methods.reject! {|m| [:params].any? {|p| m.search("params[@name=#{p}]").length == 0 } } if [:params] methods end |