Class: Epages::Variation

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/epages/variation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

build_shop_from, camelize_keys, camelize_words, options_to_multipart_request, options_to_patch_request, parse_attribute_as, parse_attribute_as_array_of, parse_attributes, symbolize_keys!, to_query_options, underscorize_keys

Constructor Details

#initialize(data) ⇒ Variation

Returns a new instance of Variation.



9
10
11
# File 'lib/epages/variation.rb', line 9

def initialize(data)
  parse_attributes(data)
end

Instance Attribute Details

#attribute_selectionObject (readonly)

Returns the value of attribute attribute_selection.



7
8
9
# File 'lib/epages/variation.rb', line 7

def attribute_selection
  @attribute_selection
end

Returns the value of attribute link.



7
8
9
# File 'lib/epages/variation.rb', line 7

def link
  @link
end

Instance Method Details

#product_idObject Also known as: id

returns the product_id of the variation



19
20
21
# File 'lib/epages/variation.rb', line 19

def product_id
  url.split('/').last
end

#propertiesObject Also known as: attributes

returns a hash formatting the property and the respective value as a pair of the hash



24
25
26
# File 'lib/epages/variation.rb', line 24

def properties
  Hash[attribute_selection.collect { |el| [el[:name].downcase.to_sym, el[:value]] }]
end

#urlObject

returns the url of the variation



14
15
16
# File 'lib/epages/variation.rb', line 14

def url
  link.href
end