Class: FeedParser
- Inherits:
-
Object
- Object
- FeedParser
- Defined in:
- lib/feed_parser.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#site_id ⇒ Object
readonly
Returns the value of attribute site_id.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#vendor_id ⇒ Object
readonly
Returns the value of attribute vendor_id.
Instance Method Summary collapse
- #create_coupons_from_xml(xml) ⇒ Object
-
#initialize(site_id, vendor_id) ⇒ FeedParser
constructor
A new instance of FeedParser.
Constructor Details
#initialize(site_id, vendor_id) ⇒ FeedParser
Returns a new instance of FeedParser.
5 6 7 8 |
# File 'lib/feed_parser.rb', line 5 def initialize(site_id, vendor_id) @vendor_id = vendor_id @site_id = site_id end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
3 4 5 |
# File 'lib/feed_parser.rb', line 3 def headers @headers end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/feed_parser.rb', line 3 def params @params end |
#site_id ⇒ Object (readonly)
Returns the value of attribute site_id.
3 4 5 |
# File 'lib/feed_parser.rb', line 3 def site_id @site_id end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
3 4 5 |
# File 'lib/feed_parser.rb', line 3 def uri @uri end |
#vendor_id ⇒ Object (readonly)
Returns the value of attribute vendor_id.
3 4 5 |
# File 'lib/feed_parser.rb', line 3 def vendor_id @vendor_id end |
Instance Method Details
#create_coupons_from_xml(xml) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/feed_parser.rb', line 10 def create_coupons_from_xml(xml) doc = FeedMapper.massage_feed(xml) (doc.xpath("//item")).each do |item| advertiser_id = item.xpath("./advertiser-id/text()") item_id = item.xpath("./item-id/text()") unless(item_id.to_s.empty?) coupon = Coupon.find_or_create_by_advertiser_id_and_item_id(advertiser_id.to_s, item_id.to_s) coupon = CouponFactory.update_coupon_with_item(coupon,item, @site_id, @vendor_id) coupon.save end end end |