Class: JQuery::Method

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elem) ⇒ Method

Returns a new instance of Method.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/jquery-cheat.rb', line 13

def initialize elem
  @name        = elem.attributes["name"]
  @short       = elem.attributes["short"]
  @long        = elem.search("> desc").inner_text
  @cat         = elem.attributes["cat"]
  @params      = elem.search("params").inject({}) {|s,p| s.merge(p.attributes["name"] => [p.search("desc").inner_text, p.attributes["type"]]) }
  @param_order = elem.search("params").map {|p| p.attributes["name"]}
  @options     = elem.search("options").inject({}) {|s,p| s.merge(p.attributes["name"] => [p.search("desc").inner_text, p.attributes["type"]]) }
  @type        = elem.attributes["type"]
  @examples    = elem.search("examples").map do |example|
    {:desc     => example.search("desc").inner_text,
     :before   => example.search("before").inner_text,
     :code     => example.search("code").inner_text,
     :result   => example.search("result").inner_text
    }
  
  end
  @attributes = elem.attributes
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



11
12
13
# File 'lib/jquery-cheat.rb', line 11

def attributes
  @attributes
end

#catObject

Returns the value of attribute cat.



11
12
13
# File 'lib/jquery-cheat.rb', line 11

def cat
  @cat
end

#examplesObject

Returns the value of attribute examples.



11
12
13
# File 'lib/jquery-cheat.rb', line 11

def examples
  @examples
end

#longObject

Returns the value of attribute long.



11
12
13
# File 'lib/jquery-cheat.rb', line 11

def long
  @long
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/jquery-cheat.rb', line 11

def name
  @name
end

#optionsObject

Returns the value of attribute options.



11
12
13
# File 'lib/jquery-cheat.rb', line 11

def options
  @options
end

#param_orderObject

Returns the value of attribute param_order.



11
12
13
# File 'lib/jquery-cheat.rb', line 11

def param_order
  @param_order
end

#paramsObject

Returns the value of attribute params.



11
12
13
# File 'lib/jquery-cheat.rb', line 11

def params
  @params
end

#shortObject

Returns the value of attribute short.



11
12
13
# File 'lib/jquery-cheat.rb', line 11

def short
  @short
end

#typeObject

Returns the value of attribute type.



11
12
13
# File 'lib/jquery-cheat.rb', line 11

def type
  @type
end

Instance Method Details

#signatureObject



33
34
35
# File 'lib/jquery-cheat.rb', line 33

def signature
  "#{name}#{"(#{ param_order.join(", ") })" if !attributes["property"] } in #{cat}"
end