Class: Nokogiri::XML::Element
- Inherits:
-
Object
- Object
- Nokogiri::XML::Element
- Defined in:
- lib/jiraSOAP/nokogiri_extensions.rb
Overview
Monkey (Freedom) patches to Nokogiri
Instance Method Summary collapse
- #children_as_object(klass) ⇒ Object
-
#children_as_objects(klass) ⇒ Array
An array of klass objects.
-
#contents_of_children ⇒ Object
Ideally this method will return an array of strings, but this may not always be the case.
-
#to_boolean ⇒ Boolean
We assume that the boolean is encoded as as string, because that how JIRA is doing right now, but the XML schema allows a boolean to be encoded as 0/1 numbers instead.
-
#to_color_triple ⇒ Array(String,String,String)?
(also: #to_colour_triple)
This is a bit naive, but should be sufficient for its purpose.
- #to_i ⇒ Fixnum
- #to_iso_date ⇒ Time?
-
#to_natural_date ⇒ Time?
Parses non-strict date strings into Time objects.
- #to_url ⇒ URI::HTTP, ...
Instance Method Details
#children_as_object(klass) ⇒ Object
59 60 61 |
# File 'lib/jiraSOAP/nokogiri_extensions.rb', line 59 def children_as_object klass klass.new_with_xml self end |
#children_as_objects(klass) ⇒ Array
Returns an array of klass objects.
65 66 67 |
# File 'lib/jiraSOAP/nokogiri_extensions.rb', line 65 def children_as_objects klass children.map { |node| klass.new_with_xml node } end |
#contents_of_children ⇒ Object
Ideally this method will return an array of strings, but this may not always be the case.
54 55 56 |
# File 'lib/jiraSOAP/nokogiri_extensions.rb', line 54 def contents_of_children children.map { |val| val.content } end |
#to_boolean ⇒ Boolean
We assume that the boolean is encoded as as string, because that how JIRA is doing right now, but the XML schema allows a boolean to be encoded as 0/1 numbers instead.
31 32 33 |
# File 'lib/jiraSOAP/nokogiri_extensions.rb', line 31 def to_boolean content == 'true' # || content == 1 end |
#to_color_triple ⇒ Array(String,String,String)? Also known as: to_colour_triple
This is a bit naive, but should be sufficient for its purpose.
45 46 47 48 |
# File 'lib/jiraSOAP/nokogiri_extensions.rb', line 45 def to_color_triple return if (temp = content).empty? temp.match(/#(..)(..)(..)/).captures end |
#to_i ⇒ Fixnum
6 7 8 |
# File 'lib/jiraSOAP/nokogiri_extensions.rb', line 6 def to_i content.to_i end |
#to_iso_date ⇒ Time?
11 12 13 14 |
# File 'lib/jiraSOAP/nokogiri_extensions.rb', line 11 def to_iso_date return if (temp = content).empty? Time.iso8601 temp end |
#to_natural_date ⇒ Time?
Parses non-strict date strings into Time objects.
20 21 22 23 |
# File 'lib/jiraSOAP/nokogiri_extensions.rb', line 20 def to_natural_date return if (temp = content).empty? Time.new temp end |
#to_url ⇒ URI::HTTP, ...
36 37 38 39 |
# File 'lib/jiraSOAP/nokogiri_extensions.rb', line 36 def to_url return if (temp = content).empty? JIRA.url_class.send JIRA.url_init_method, temp end |