Class: DJNML::Modification
- Inherits:
-
Object
- Object
- DJNML::Modification
- Defined in:
- lib/djnml/modification.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#doc_date ⇒ Object
readonly
Returns the value of attribute doc_date.
-
#headline ⇒ Object
readonly
Returns the value of attribute headline.
-
#mdata ⇒ Object
readonly
Returns the value of attribute mdata.
-
#press_cutout ⇒ Object
readonly
Returns the value of attribute press_cutout.
-
#product ⇒ Object
readonly
Returns the value of attribute product.
-
#publisher ⇒ Object
readonly
Returns the value of attribute publisher.
-
#seq ⇒ Object
readonly
Returns the value of attribute seq.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#urgency ⇒ Object
readonly
Returns the value of attribute urgency.
-
#xpath ⇒ Object
readonly
Returns the value of attribute xpath.
Instance Method Summary collapse
- #fields_to_modify ⇒ Object
-
#initialize(args = {}) ⇒ Modification
constructor
A new instance of Modification.
Constructor Details
#initialize(args = {}) ⇒ Modification
Returns a new instance of Modification.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/djnml/modification.rb', line 32 def initialize(args = {}) @publisher = args[:publisher] if args[:publisher] @doc_date = Time.parse(args[:doc_date]) if args[:doc_date] @product = args[:product] if args[:product] @seq = args[:seq].to_i if args[:seq] xml = args[:xml] if args[:xml] if xml && xml.is_a?(Nokogiri::XML::Element) @xpath = xml['xpath'] if mdata = xml.search('djn-mdata').to_a.first @mdata = Mdata.new(mdata) end if headline = xml.search('headline').to_a.first @headline = headline.text.strip end if text = xml.search('text').to_a.first @text = XMLText.new(text) end if text = xml.search('summary').to_a.first @summary = XMLText.new(text) end if press = xml.search('djn-press-cutout').to_a.first @press_cutout = press.text.strip end if urgency = xml.search('djn-urgency').to_a.first @urgency = urgency.text.strip end else @publisher = args['publisher'] if args['publisher'] @doc_date = Time.parse(args['doc_date']) if args['doc_date'] @product = args['product'] if args['product'] @seq = args['seq'].to_i if args['seq'] @mdata = Mdata.new(args['mdata']) if args['mdata'] @headline = args['headline'] if args['headline'] @text = XMLText.new(args['text']) if args['text'] @summary = XMLText.new(args['summary']) if args['summary'] @press_cutout = args['press_cutout'] if args['press_cutout'] @urgency = args['urgency'] if args['urgency'] end end |
Instance Attribute Details
#doc_date ⇒ Object (readonly)
Returns the value of attribute doc_date.
29 30 31 |
# File 'lib/djnml/modification.rb', line 29 def doc_date @doc_date end |
#headline ⇒ Object (readonly)
Returns the value of attribute headline.
29 30 31 |
# File 'lib/djnml/modification.rb', line 29 def headline @headline end |
#mdata ⇒ Object (readonly)
Returns the value of attribute mdata.
29 30 31 |
# File 'lib/djnml/modification.rb', line 29 def mdata @mdata end |
#press_cutout ⇒ Object (readonly)
Returns the value of attribute press_cutout.
29 30 31 |
# File 'lib/djnml/modification.rb', line 29 def press_cutout @press_cutout end |
#product ⇒ Object (readonly)
Returns the value of attribute product.
29 30 31 |
# File 'lib/djnml/modification.rb', line 29 def product @product end |
#publisher ⇒ Object (readonly)
Returns the value of attribute publisher.
29 30 31 |
# File 'lib/djnml/modification.rb', line 29 def publisher @publisher end |
#seq ⇒ Object (readonly)
Returns the value of attribute seq.
29 30 31 |
# File 'lib/djnml/modification.rb', line 29 def seq @seq end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
29 30 31 |
# File 'lib/djnml/modification.rb', line 29 def summary @summary end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
29 30 31 |
# File 'lib/djnml/modification.rb', line 29 def text @text end |
#urgency ⇒ Object (readonly)
Returns the value of attribute urgency.
29 30 31 |
# File 'lib/djnml/modification.rb', line 29 def urgency @urgency end |
#xpath ⇒ Object (readonly)
Returns the value of attribute xpath.
29 30 31 |
# File 'lib/djnml/modification.rb', line 29 def xpath @xpath end |
Instance Method Details
#fields_to_modify ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/djnml/modification.rb', line 81 def fields_to_modify fields = [] [:mdata, :headline, :text, :urgency, :press_cutout, :summary].each do |f| if self.send(f) fields << f end end fields end |