class Taobao::Property

Attributes

multi[R]
must[R]
name[R]
pid[R]
values[R]

Public Class Methods

new(response) click to toggle source

@param response [Hash]

# File lib/taobao/property.rb, line 6
def initialize(response)
  @response = response
  to_object response
  @values = get_values
  raise Taobao::IncorrectProperty, 'Incorrect property data' unless @name
  convert_data_types
end

Private Instance Methods

convert_data_types() click to toggle source
# File lib/taobao/property.rb, line 21
def convert_data_types
  @must = @must == 'true'
  @multi = @multi == 'true'
  @pid = @pid.to_i
  @values.map! do |v|
    v[:vid] = v[:vid].to_i
    v[:is_parent] = v[:is_parent] == 'true'
    v
  end
end
get_values() click to toggle source
# File lib/taobao/property.rb, line 15
def get_values
  @response[:prop_values][:prop_value]
rescue NoMethodError
  []
end