Class: Stilts::Batch

Inherits:
Object
  • Object
show all
Defined in:
lib/stilts/batch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBatch

Batch is just an array of images



7
8
9
# File 'lib/stilts/batch.rb', line 7

def initialize
  self.images = []
end

Instance Attribute Details

#imagesObject

Returns the value of attribute images.



4
5
6
# File 'lib/stilts/batch.rb', line 4

def images
  @images
end

Instance Method Details

#<<(image) ⇒ Object

:nodoc:



22
23
24
# File 'lib/stilts/batch.rb', line 22

def << image
  self.images << image
end

#deliverObject

Send images to Stilts for transformation, first screen and translate to_json



12
13
14
# File 'lib/stilts/batch.rb', line 12

def deliver
  Stilts.sender.send_image_transform_data(self.to_json)
end

#empty?Boolean

:nodoc:

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/stilts/batch.rb', line 33

def empty?
  return true if self.size == 0
  false
end

#sizeObject Also known as: length

:nodoc:



27
28
29
# File 'lib/stilts/batch.rb', line 27

def size
  self.images.size
end

#to_jsonObject

Ready images for transport across voidy vastness of teh interweb



17
18
19
# File 'lib/stilts/batch.rb', line 17

def to_json
  JSON.generate(self.images.collect{|i| i.to_hash})
end