Class: PrintNode::PrintJob

Inherits:
Object
  • Object
show all
Defined in:
lib/printnode/printjob.rb

Overview

An object for printjob creation.

Author:

  • Jake Torrance

  • PrintNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(printer_id, title, content_type, content, source) ⇒ PrintJob

Initializes the object with the variables required.



29
30
31
32
33
34
35
# File 'lib/printnode/printjob.rb', line 29

def initialize(printer_id, title, content_type, content, source)
  @printer_id = printer_id
  @title = title
  @content_type = content_type
  @content = content
  @source = source
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



10
11
12
# File 'lib/printnode/printjob.rb', line 10

def content
  @content
end

#content_typeObject

Returns the value of attribute content_type.



9
10
11
# File 'lib/printnode/printjob.rb', line 9

def content_type
  @content_type
end

#printer_idObject

Returns the value of attribute printer_id.



7
8
9
# File 'lib/printnode/printjob.rb', line 7

def printer_id
  @printer_id
end

#sourceObject

Returns the value of attribute source.



11
12
13
# File 'lib/printnode/printjob.rb', line 11

def source
  @source
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/printnode/printjob.rb', line 8

def title
  @title
end

Instance Method Details

#to_hashObject

Maps the object into a hash ready for JSON Encoding.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/printnode/printjob.rb', line 14

def to_hash
  hash = {}
  hash['printerId'] = @printer_id
  hash['title'] = @title
  hash['contentType'] = @content_type
  if @content_type.match('base64$')
    hash ['content'] = Base64.encode64(IO.read(@content))
  else
    hash ['content'] = @content
  end
  hash['source'] = @source
  hash
end