Class: Peddler::Marketplace Private

Inherits:
Struct
  • Object
show all
Defined in:
lib/peddler/marketplace.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.allObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
# File 'lib/peddler/marketplace.rb', line 8

def all
  @all
end

Instance Attribute Details

#country_codeObject

Returns the value of attribute country_code

Returns:

  • (Object)

    the current value of country_code



6
7
8
# File 'lib/peddler/marketplace.rb', line 6

def country_code
  @country_code
end

#hostObject

Returns the value of attribute host

Returns:

  • (Object)

    the current value of host



6
7
8
# File 'lib/peddler/marketplace.rb', line 6

def host
  @host
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



6
7
8
# File 'lib/peddler/marketplace.rb', line 6

def id
  @id
end

Class Method Details

.find(key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/peddler/marketplace.rb', line 10

def find(key)
  marketplace = if key.nil?
                  missing_key!
                elsif key.size == 2
                  find_by_country_code(key)
                else
                  find_by_id(key)
                end

  marketplace || not_found!(key)
end

Instance Method Details

#encodingObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Caveat: We use supersets Windows-31J and CP1252 in place of Shift_JIS and ISO 8859-1 respectively to handle some edge cases. These should be safe to drop in as replacements.



45
46
47
48
49
50
51
52
53
54
# File 'lib/peddler/marketplace.rb', line 45

def encoding
  case country_code
  when 'JP'
    'Windows-31J'
  when 'CN'
    'UTF-16'
  else
    'CP1252'
  end
end