Class: Dustbag::ItemAttributes

Inherits:
Object
  • Object
show all
Includes:
Parser::Node
Defined in:
lib/dustbag/item_attributes.rb

Instance Attribute Summary

Attributes included from Parser::Node

#node, #subnodes

Instance Method Summary collapse

Methods included from Parser::Node

included, #initialize, #repeated_subnodes, #repeated_subnodes_text, #subnode, #subnode_text

Instance Method Details

#actorsObject



22
23
24
# File 'lib/dustbag/item_attributes.rb', line 22

def actors
  repeated_subnodes_text('Actor')
end

#adult_product?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/dustbag/item_attributes.rb', line 75

def adult_product?
  subnode_text('IsAdultProduct') == '1'
end

#authorsObject



33
34
35
# File 'lib/dustbag/item_attributes.rb', line 33

def authors
  repeated_subnodes_text('Author')
end

#creatorsObject



26
27
28
29
30
31
# File 'lib/dustbag/item_attributes.rb', line 26

def creators
  repeated_subnodes('Creator').inject({}) do |acc, val|
    acc[val['Role']] = val.text
    acc
  end
end

#ean_listObject



37
38
39
40
41
42
# File 'lib/dustbag/item_attributes.rb', line 37

def ean_list
  list = subnode('EANList')
  list && list.locate('EANListElement').map do |element|
    element.text
  end
end

#featuresObject



44
45
46
# File 'lib/dustbag/item_attributes.rb', line 44

def features
  repeated_subnodes_text('Feature')
end

#labelsObject



48
49
50
# File 'lib/dustbag/item_attributes.rb', line 48

def labels
  repeated_subnodes_text('Label')
end

#list_priceObject



63
64
65
# File 'lib/dustbag/item_attributes.rb', line 63

def list_price
  Price.parse(subnode('ListPrice'))
end

#publication_dateObject



71
72
73
# File 'lib/dustbag/item_attributes.rb', line 71

def publication_date
  Date.parse(subnode_text('PublicationDate')) rescue nil
end

#release_dateObject



67
68
69
# File 'lib/dustbag/item_attributes.rb', line 67

def release_date
  Date.parse(subnode_text('ReleaseDate')) rescue nil
end

#trade_in_valueObject



52
53
54
# File 'lib/dustbag/item_attributes.rb', line 52

def trade_in_value
  Price.parse(subnode('TradeInValue'))
end

#upc_listObject



56
57
58
59
60
61
# File 'lib/dustbag/item_attributes.rb', line 56

def upc_list
  list = subnode('UPCList')
  list && list.locate('UPCListElement').map do |element|
    element.text
  end
end