Class: Masklen::Locale

Inherits:
Struct
  • Object
show all
Defined in:
lib/masklen/types.rb

Overview

Locale and regional data for an IP address.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#calling_codeObject

Returns the value of attribute calling_code

Returns:

  • (Object)

    the current value of calling_code



78
79
80
# File 'lib/masklen/types.rb', line 78

def calling_code
  @calling_code
end

#currencyObject

Returns the value of attribute currency

Returns:

  • (Object)

    the current value of currency



78
79
80
# File 'lib/masklen/types.rb', line 78

def currency
  @currency
end

#currency_symbolObject

Returns the value of attribute currency_symbol

Returns:

  • (Object)

    the current value of currency_symbol



78
79
80
# File 'lib/masklen/types.rb', line 78

def currency_symbol
  @currency_symbol
end

#flagObject

Returns the value of attribute flag

Returns:

  • (Object)

    the current value of flag



78
79
80
# File 'lib/masklen/types.rb', line 78

def flag
  @flag
end

#languagesObject

Returns the value of attribute languages

Returns:

  • (Object)

    the current value of languages



78
79
80
# File 'lib/masklen/types.rb', line 78

def languages
  @languages
end

Class Method Details

.from_hash(hash) ⇒ Object

Build a Locale from a parsed JSON hash. Returns nil if hash is nil.



87
88
89
90
91
92
93
94
95
96
97
# File 'lib/masklen/types.rb', line 87

def self.from_hash(hash)
  return nil if hash.nil?

  new(
    currency:        hash["currency"],
    currency_symbol: hash["currency_symbol"],
    calling_code:    hash["calling_code"],
    languages:       hash["languages"] || [],
    flag:            hash["flag"]
  )
end