Class: MistApi::MapSiteReplaceFileJsonTransform

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/map_site_replace_file_json_transform.rb

Overview

If ‘transform` is provided, all the locations of the objects on the map (AP, Zone, Vbeacon, Beacon) will be transformed as well (relative to the new Map)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(rotation = 0, scale = 1, x = 0, y = 0) ⇒ MapSiteReplaceFileJsonTransform

Returns a new instance of MapSiteReplaceFileJsonTransform.



54
55
56
57
58
59
# File 'lib/mist_api/models/map_site_replace_file_json_transform.rb', line 54

def initialize(rotation = 0, scale = 1, x = 0, y = 0)
  @rotation = rotation unless rotation == SKIP
  @scale = scale unless scale == SKIP
  @x = x unless x == SKIP
  @y = y unless y == SKIP
end

Instance Attribute Details

#rotationFloat

Whether to rotate the replacing image, in degrees

Returns:

  • (Float)


15
16
17
# File 'lib/mist_api/models/map_site_replace_file_json_transform.rb', line 15

def rotation
  @rotation
end

#scaleFloat

Whether to scale the replacing image

Returns:

  • (Float)


19
20
21
# File 'lib/mist_api/models/map_site_replace_file_json_transform.rb', line 19

def scale
  @scale
end

#xFloat

Where the (0, 0) of the new image is relative to the original map

Returns:

  • (Float)


23
24
25
# File 'lib/mist_api/models/map_site_replace_file_json_transform.rb', line 23

def x
  @x
end

#yFloat

Where the (0, 0) of the new image is relative to the original map

Returns:

  • (Float)


27
28
29
# File 'lib/mist_api/models/map_site_replace_file_json_transform.rb', line 27

def y
  @y
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/mist_api/models/map_site_replace_file_json_transform.rb', line 62

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  rotation = hash['rotation'] ||= 0
  scale = hash['scale'] ||= 1
  x = hash['x'] ||= 0
  y = hash['y'] ||= 0

  # Create object from extracted values.
  MapSiteReplaceFileJsonTransform.new(rotation,
                                      scale,
                                      x,
                                      y)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/mist_api/models/map_site_replace_file_json_transform.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['rotation'] = 'rotation'
  @_hash['scale'] = 'scale'
  @_hash['x'] = 'x'
  @_hash['y'] = 'y'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/mist_api/models/map_site_replace_file_json_transform.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
46
47
# File 'lib/mist_api/models/map_site_replace_file_json_transform.rb', line 40

def self.optionals
  %w[
    rotation
    scale
    x
    y
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



85
86
87
88
89
# File 'lib/mist_api/models/map_site_replace_file_json_transform.rb', line 85

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} rotation: #{@rotation.inspect}, scale: #{@scale.inspect}, x: #{@x.inspect},"\
  " y: #{@y.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



79
80
81
82
# File 'lib/mist_api/models/map_site_replace_file_json_transform.rb', line 79

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} rotation: #{@rotation}, scale: #{@scale}, x: #{@x}, y: #{@y}>"
end