Class: Nexaas::Async::Collector::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/nexaas/async/collector/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope_id, id) ⇒ Result

Returns a new instance of Result.



16
17
18
19
20
# File 'lib/nexaas/async/collector/result.rb', line 16

def initialize(scope_id, id)
  @scope_id = scope_id
  @id = id
  @storage = Storage.new
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/nexaas/async/collector/result.rb', line 14

def id
  @id
end

#scope_idObject (readonly)

Returns the value of attribute scope_id.



14
15
16
# File 'lib/nexaas/async/collector/result.rb', line 14

def scope_id
  @scope_id
end

#storageObject (readonly)

Returns the value of attribute storage.



14
15
16
# File 'lib/nexaas/async/collector/result.rb', line 14

def storage
  @storage
end

Instance Method Details

#contentObject



22
23
24
# File 'lib/nexaas/async/collector/result.rb', line 22

def content
  Base64.decode64(object['content']) if content_is_ready?
end

#content_is_ready?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/nexaas/async/collector/result.rb', line 26

def content_is_ready?
  object && object['scope_id'] == scope_id && object['content']
end

#content_typeObject



38
39
40
# File 'lib/nexaas/async/collector/result.rb', line 38

def content_type
  object && object.dig('file', 'content_type')
end

#extensionObject



42
43
44
# File 'lib/nexaas/async/collector/result.rb', line 42

def extension
  object && object.dig('file', 'extension')
end

#filenameObject



34
35
36
# File 'lib/nexaas/async/collector/result.rb', line 34

def filename
  object && object.dig('file', 'name')
end

#is_file?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/nexaas/async/collector/result.rb', line 30

def is_file?
  object && !object['file'].nil?
end