Class: Moo::Model::ImageData

Inherits:
Data show all
Defined in:
lib/moo/model/image_data.rb

Instance Attribute Summary collapse

Attributes inherited from Data

#link_id

Instance Method Summary collapse

Methods inherited from Data

#type

Constructor Details

#initialize {|_self| ... } ⇒ ImageData

Returns a new instance of ImageData.

Yields:

  • (_self)

Yield Parameters:



6
7
8
9
# File 'lib/moo/model/image_data.rb', line 6

def initialize
  @enhance = false
  yield self if block_given?
end

Instance Attribute Details

#enhanceObject

Returns the value of attribute enhance.



4
5
6
# File 'lib/moo/model/image_data.rb', line 4

def enhance
  @enhance
end

#image_boxObject

Returns the value of attribute image_box.



4
5
6
# File 'lib/moo/model/image_data.rb', line 4

def image_box
  @image_box
end

#image_store_file_idObject

Returns the value of attribute image_store_file_id.



4
5
6
# File 'lib/moo/model/image_data.rb', line 4

def image_store_file_id
  @image_store_file_id
end

#resource_uriObject

Returns the value of attribute resource_uri.



4
5
6
# File 'lib/moo/model/image_data.rb', line 4

def resource_uri
  @resource_uri
end

Instance Method Details

#from_hash(hash) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/moo/model/image_data.rb', line 49

def from_hash hash
  self.link_id = hash[:linkId]
  b = BoundingBox.new
  b.from_json(hash[:imageBox].to_json)
  self.image_box = b
  self.resource_uri = hash[:resourceUri]
  self.image_store_file_id = hash[:imageStoreFileId] if hash[:imageStoreFileId]
  self.enhance = hash[:enhance]
end

#from_json(json) ⇒ Object



59
60
61
# File 'lib/moo/model/image_data.rb', line 59

def from_json json
  from_hash(JSON.parse(json, :symbolize_names => true))
end

#to_hashObject



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/moo/model/image_data.rb', line 37

def to_hash
  hash = {
    type: type,
    linkId: link_id,
    imageBox: image_box.to_hash,
    resourceUri: resource_uri,
  }
  hash[:imageStoreFileId] = image_store_file_id unless image_store_file_id.nil?
  hash[:enhance] = enhance
  hash
end

#to_jsonObject



33
34
35
# File 'lib/moo/model/image_data.rb', line 33

def to_json
  to_hash.to_json
end