Class: TitlePage::Stock

Inherits:
Response show all
Defined in:
lib/titlepage/utils.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#on_handObject

Returns the value of attribute on_hand.



101
102
103
# File 'lib/titlepage/utils.rb', line 101

def on_hand
  @on_hand
end

#on_orderObject

Returns the value of attribute on_order.



102
103
104
# File 'lib/titlepage/utils.rb', line 102

def on_order
  @on_order
end

Class Method Details

.from_xml(node) ⇒ Object

convert a nokogiri node to a TitlePage::Stock object



106
107
108
109
110
111
112
113
114
115
116
# File 'lib/titlepage/utils.rb', line 106

def self.from_xml(node)
  return nil if node.nil?
  #<Stock xsi:type="tns:Stock">
  #  <OnHand xsi:type="xsd:string">Out Of Stock</OnHand>
  #  <OnOrder xsi:type="xsd:string">Yes</OnOrder>
  #</Stock>
  stock = self.new
  stock.on_hand = node.xpath("//Stock/OnHand/text()").first.andand.to_s
  stock.on_order = node.xpath("//Stock/OnOrder/text()").first.andand.to_s
  stock
end