Class: Nwsdk::Content
- Inherits:
-
Object
- Object
- Nwsdk::Content
- Defined in:
- lib/nwsdk/content.rb
Constant Summary
Constants included from Constants
Nwsdk::Constants::DEFAULT_CONFIG, Nwsdk::Constants::NW_CONTENT_FLAG_STREAM1, Nwsdk::Constants::NW_CONTENT_TYPE_AUTO, Nwsdk::Constants::NW_TIME_FORMAT, Nwsdk::Constants::NW_VARIANT_DAYS
Constants included from Helpers
Helpers::ATTACHMENT_FILENAME, Helpers::MULTIPART_BOUNDARY, Helpers::MULTIPART_END, Helpers::MULTIPART_PROLOGUE
Instance Attribute Summary collapse
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#exclude_types ⇒ Object
Returns the value of attribute exclude_types.
-
#include_types ⇒ Object
Returns the value of attribute include_types.
-
#output_dir ⇒ Object
Returns the value of attribute output_dir.
Instance Method Summary collapse
- #build_params(session) ⇒ Object
- #build_request(session) ⇒ Object
- #each_session ⇒ Object
- #each_session_file ⇒ Object
-
#initialize(*args) ⇒ Content
constructor
A new instance of Content.
Methods included from Helpers
#count_results, #decode_value, #each_multipart_response_entity, #format_timestamp, #get_boundary, #get_sessionids, #response_successful?
Constructor Details
#initialize(*args) ⇒ Content
Returns a new instance of Content.
9 10 11 12 13 14 |
# File 'lib/nwsdk/content.rb', line 9 def initialize(*args) Hash[*args].each {|k,v| self.send('%s='%k, v)} @include_types ||= [] @exclude_types ||= [] @output_dir ||= 'tmp' end |
Instance Attribute Details
#condition ⇒ Object
Returns the value of attribute condition.
6 7 8 |
# File 'lib/nwsdk/content.rb', line 6 def condition @condition end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
6 7 8 |
# File 'lib/nwsdk/content.rb', line 6 def endpoint @endpoint end |
#exclude_types ⇒ Object
Returns the value of attribute exclude_types.
6 7 8 |
# File 'lib/nwsdk/content.rb', line 6 def exclude_types @exclude_types end |
#include_types ⇒ Object
Returns the value of attribute include_types.
6 7 8 |
# File 'lib/nwsdk/content.rb', line 6 def include_types @include_types end |
#output_dir ⇒ Object
Returns the value of attribute output_dir.
6 7 8 |
# File 'lib/nwsdk/content.rb', line 6 def output_dir @output_dir end |
Instance Method Details
#build_params(session) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/nwsdk/content.rb', line 47 def build_params(session) send_params={ session: session, maxSize: 0, render: NW_CONTENT_TYPE_FILE_EXTRACTOR } unless include_types.empty? send_params[:includeFileTypes]=include_types.join(';') end unless exclude_types.empty? send_params[:excludeFileTypes]=exclude_types.join(';') end send_params end |
#build_request(session) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/nwsdk/content.rb', line 16 def build_request(session) endpoint.get_request( path: 'sdk/content', params: build_params(session) ) end |
#each_session ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nwsdk/content.rb', line 23 def each_session sessions=get_sessionids(self) sessions.each do |sessionid| begin response=build_request(sessionid).execute rescue RestClient::Gone next end next unless response.code==200 yield response end end |
#each_session_file ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nwsdk/content.rb', line 36 def each_session_file each_session do |response| content=response.body.encode('BINARY') next unless response.headers.has_key? :content_type boundary=get_boundary(response.headers[:content_type]) each_multipart_response_entity(content,boundary) do |file| yield file end end end |