Class: VastApi::Listings
- Inherits:
-
Array
- Object
- Array
- VastApi::Listings
- Defined in:
- lib/vast_api/listings.rb,
lib/vast_api/listings/entry.rb
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#vast ⇒ Object
readonly
Returns the value of attribute vast.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Class Method Summary collapse
Instance Method Summary collapse
- #attr(var_name) ⇒ Object
-
#initialize(vast) ⇒ Listings
constructor
A new instance of Listings.
- #query ⇒ Object
Constructor Details
#initialize(vast) ⇒ Listings
Returns a new instance of Listings.
7 8 9 10 11 12 13 |
# File 'lib/vast_api/listings.rb', line 7 def initialize(vast) @vast = vast @url = "#{@vast.api_url}listings/-/#{@vast.category}?#{@vast.query}" @response = Typhoeus::Request.get(@url) @xml = Nokogiri::XML(@response.body) populate end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/vast_api/listings.rb', line 3 def attributes @attributes end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/vast_api/listings.rb', line 3 def response @response end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/vast_api/listings.rb', line 3 def url @url end |
#vast ⇒ Object (readonly)
Returns the value of attribute vast.
3 4 5 |
# File 'lib/vast_api/listings.rb', line 3 def vast @vast end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
3 4 5 |
# File 'lib/vast_api/listings.rb', line 3 def xml @xml end |
Class Method Details
Instance Method Details
#attr(var_name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vast_api/listings.rb', line 15 def attr(var_name) if var = @xml.at(var_name) var.text elsif var = @xml.at('//v:'+var_name) var.text elsif var = @xml.at('//o:'+var_name) var.text else nil end end |
#query ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/vast_api/listings.rb', line 27 def query if @query.nil? @query = {} @xml.at('//o:Query').attributes.each do |name,value| @query[name] = value.value end end @query end |