Class: InewsClient::Queue
- Inherits:
-
Struct
- Object
- Struct
- InewsClient::Queue
- Defined in:
- lib/inews_client/queue.rb
Instance Attribute Summary collapse
-
#inews ⇒ Object
Returns the value of attribute inews.
Instance Method Summary collapse
- #client ⇒ Object
- #client_options ⇒ Object
- #ensure_connected! ⇒ Object
- #get_queue_records ⇒ Object
- #get_stories(options) ⇒ Object
- #set_current_queue(queue_full_path) ⇒ Object
- #stories(options) ⇒ Object
- #with_queue(options, &block) ⇒ Object
Instance Attribute Details
#inews ⇒ Object
Returns the value of attribute inews
2 3 4 |
# File 'lib/inews_client/queue.rb', line 2 def inews @inews end |
Instance Method Details
#client ⇒ Object
48 49 50 |
# File 'lib/inews_client/queue.rb', line 48 def client @client ||= Savon.client() end |
#client_options ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/inews_client/queue.rb', line 3 def { wsdl: "#{ENV['wsdl']}/inewswebservice/services/inewsqueue?wsdl", namespaces:{ "xmlns:types" => "http://avid.com/inewsqueue/types", }, } end |
#ensure_connected! ⇒ Object
52 53 54 |
# File 'lib/inews_client/queue.rb', line 52 def ensure_connected! inews.ensure_connected! end |
#get_queue_records ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/inews_client/queue.rb', line 40 def get_queue_records = { 'types:NumberOfRecordsToGet' => '30', 'types:Reset' => '0', } client.call(:get_queue_records, message: , cookies: inews.) end |
#get_stories(options) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/inews_client/queue.rb', line 12 def get_stories() num_of_stories = ['stories_to_get'].to_i num_of_stories = 50 unless num_of_stories = { 'types:NumberOfStoriesToGet' => "#{num_of_stories}", 'types:IsStoryBodyIncluded' => 'true', 'types:Navigation' => 'SAME', } client.call(:get_stories, message: , cookies: inews.) end |
#set_current_queue(queue_full_path) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/inews_client/queue.rb', line 24 def set_current_queue(queue_full_path) = { 'types:QueueFullName' => queue_full_path, } client.call(:set_current_queue, message: , cookies: inews.) end |
#stories(options) ⇒ Object
36 37 38 |
# File 'lib/inews_client/queue.rb', line 36 def stories() get_stories().to_array(:get_stories_response, :stories).map { |story| StoryEntry.parse(story[:story_as_nsml]) } end |
#with_queue(options, &block) ⇒ Object
31 32 33 34 |
# File 'lib/inews_client/queue.rb', line 31 def with_queue(, &block) set_current_queue(['current_queue']) block.call(inews.queue) end |