Class: Jamf::Locales

Inherits:
SingletonResource show all
Extended by:
Immutable
Defined in:
lib/jamf/api/resources/singleton_resources/locales.rb

Overview

A list of known timezones

Constant Summary collapse

RSRC_VERSION =

Constants

'v1'.freeze
RSRC_PATH =
'locales'.freeze
OBJECT_MODEL =
{

  # @!attribute checkInFrequency
  #   @return [integer]
  locales: {
    class: Jamf::Locale,
    multi: true,
    read_only: true,
    aliases: [:list]
  }

}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, cnx: Jamf.cnx) ⇒ Locales

TEMP? until this endpoint is brought up to standards the data from the API is a raw Array, but it should be a Hash containing an array.



65
66
67
68
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 65

def initialize(data, cnx: Jamf.cnx)
  data = { locales: data }
  super data, cnx: cnx
end

Class Method Details

.desc_for_id(id, refresh = false, cnx: Jamf.cnx) ⇒ Object

Class level wrapper for #desc_for_id



108
109
110
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 108

def self.desc_for_id(id, refresh = false, cnx: Jamf.cnx)
  fetch(refresh, cnx: cnx).desc_for_id id
end

.descriptions(refresh = false, cnx: Jamf.cnx) ⇒ Object

Class level wrapper for #descriptions



80
81
82
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 80

def self.descriptions(refresh = false, cnx: Jamf.cnx)
  fetch(refresh, cnx: cnx).descriptions
end

.descs_by_id(refresh = false, cnx: Jamf.cnx) ⇒ Object

Class level wrapper for #descs_by_id



98
99
100
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 98

def self.descs_by_id(refresh = false, cnx: Jamf.cnx)
  fetch(refresh, cnx: cnx).descs_by_id
end

.id_for_desc(desc, refresh = false, cnx: Jamf.cnx) ⇒ Object

Class level wrapper for #id_for_desc



103
104
105
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 103

def self.id_for_desc(desc, refresh = false, cnx: Jamf.cnx)
  fetch(refresh, cnx: cnx).id_for_desc desc
end

.identifiers(refresh = false, cnx: Jamf.cnx) ⇒ Object

Class level wrapper for #identifiers



87
88
89
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 87

def self.identifiers(refresh = false, cnx: Jamf.cnx)
  fetch(refresh, cnx: cnx).identifiers
end

.ids_by_desc(refresh = false, cnx: Jamf.cnx) ⇒ Object

Class level wrapper for #ids_by_desc



93
94
95
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 93

def self.ids_by_desc(refresh = false, cnx: Jamf.cnx)
  fetch(refresh, cnx: cnx).ids_by_desc
end

.list(refresh = false, cnx: Jamf.cnx) ⇒ Array<Jamf::Locale>

Returns all the locales available.

Returns:



75
76
77
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 75

def self.list(refresh = false, cnx: Jamf.cnx)
  fetch(refresh, cnx: cnx).locales
end

.mutable?Boolean Originally defined in module Immutable

Returns:

  • (Boolean)

Instance Method Details

#desc_for_id(id) ⇒ String

return a description from its identifier, case-insensitive

Parameters:

  • name (String)

    the identifier of a local

Returns:



148
149
150
151
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 148

def desc_for_id(id)
  id = identifiers.select { |n| n.casecmp? id }.first
  descs_by_id[id]
end

#descriptionsArray<String> Also known as: names

Returns the available descriptions.

Returns:



116
117
118
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 116

def descriptions
  @descriptions ||= locales.map(&:description)
end

#descs_by_idHash

Returns code => name.

Returns:

  • (Hash)

    code => name



133
134
135
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 133

def descs_by_id
  @descs_by_id ||= locales.map { |l| [l.identifier, l.description] }.to_h
end

#id_for_desc(desc) ⇒ String

return an identifier from its description, case-insensitive

Parameters:

  • desc (String)

    the description of a locale

Returns:



140
141
142
143
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 140

def id_for_desc(desc)
  desc = descriptions.select { |n| n.casecmp? desc }.first
  ids_by_desc[desc]
end

#identifiersArray<String> Also known as: ids

Returns the available identifiers.

Returns:



122
123
124
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 122

def identifiers
  @identifiers ||= locales.map(&:identifier)
end

#ids_by_descHash

Returns name => code.

Returns:

  • (Hash)

    name => code



128
129
130
# File 'lib/jamf/api/resources/singleton_resources/locales.rb', line 128

def ids_by_desc
  @ids_by_desc ||= locales.map { |l| [l.description, l.identifier] }.to_h
end