Class: Api2Convert::Model::Preset

Inherits:
Object
  • Object
show all
Defined in:
lib/api2convert/model/preset.rb

Overview

A saved conversion preset (a reusable named set of target + options).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, name: "", target: nil, category: nil, scope: nil, options: {}) ⇒ Preset

Returns a new instance of Preset.



9
10
11
12
13
14
15
16
17
# File 'lib/api2convert/model/preset.rb', line 9

def initialize(id: nil, name: "", target: nil, category: nil, scope: nil, options: {})
  @id = id
  @name = name
  @target = target
  @category = category
  @scope = scope
  @options = options
  freeze
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



7
8
9
# File 'lib/api2convert/model/preset.rb', line 7

def category
  @category
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/api2convert/model/preset.rb', line 7

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/api2convert/model/preset.rb', line 7

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/api2convert/model/preset.rb', line 7

def options
  @options
end

#scopeObject (readonly)

Returns the value of attribute scope.



7
8
9
# File 'lib/api2convert/model/preset.rb', line 7

def scope
  @scope
end

#targetObject (readonly)

Returns the value of attribute target.



7
8
9
# File 'lib/api2convert/model/preset.rb', line 7

def target
  @target
end

Class Method Details

.from_hash(data) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/api2convert/model/preset.rb', line 19

def self.from_hash(data)
  d = Support::Data.as_object(data)
  new(
    id: Support::Data.nullable_str(d["id"]),
    name: Support::Data.as_str(d["name"]),
    target: Support::Data.nullable_str(d["target"]),
    category: Support::Data.nullable_str(d["category"]),
    scope: Support::Data.nullable_str(d["scope"]),
    options: Support::Data.as_object(d["options"])
  )
end