Class: Epages::Variation
- Inherits:
-
Object
- Object
- Epages::Variation
- Includes:
- Utils
- Defined in:
- lib/epages/variation.rb
Instance Attribute Summary collapse
-
#attribute_selection ⇒ Object
readonly
Returns the value of attribute attribute_selection.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
Instance Method Summary collapse
-
#initialize(data) ⇒ Variation
constructor
A new instance of Variation.
-
#product_id ⇒ Object
(also: #id)
returns the product_id of the variation.
-
#properties ⇒ Object
(also: #attributes)
returns a hash formatting the property and the respective value as a pair of the hash.
-
#url ⇒ Object
returns the url of the variation.
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_selection ⇒ Object (readonly)
Returns the value of attribute attribute_selection.
7 8 9 |
# File 'lib/epages/variation.rb', line 7 def attribute_selection @attribute_selection end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
7 8 9 |
# File 'lib/epages/variation.rb', line 7 def link @link end |
Instance Method Details
#product_id ⇒ Object 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 |
#properties ⇒ Object 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 |
#url ⇒ Object
returns the url of the variation
14 15 16 |
# File 'lib/epages/variation.rb', line 14 def url link.href end |