Class: VastApi::Attributes
- Inherits:
-
Hash
- Object
- Hash
- VastApi::Attributes
- Defined in:
- lib/vast_api/attributes.rb,
lib/vast_api/attributes/entry.rb
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#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.
Instance Method Summary collapse
- #attr(var_name) ⇒ Object
-
#initialize(vast) ⇒ Attributes
constructor
A new instance of Attributes.
- #listings ⇒ Object
Constructor Details
#initialize(vast) ⇒ Attributes
Returns a new instance of Attributes.
9 10 11 12 13 14 15 |
# File 'lib/vast_api/attributes.rb', line 9 def initialize(vast) @vast = vast @url = "#{@vast.api_url}attributes/-/#{@vast.category}?#{@vast.query}" @response = Typhoeus::Request.get(@url) @xml = Nokogiri::XML(@response.body) populate end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/vast_api/attributes.rb', line 3 def response @response end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/vast_api/attributes.rb', line 3 def url @url end |
#vast ⇒ Object (readonly)
Returns the value of attribute vast.
3 4 5 |
# File 'lib/vast_api/attributes.rb', line 3 def vast @vast end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
3 4 5 |
# File 'lib/vast_api/attributes.rb', line 3 def xml @xml end |
Instance Method Details
#attr(var_name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vast_api/attributes.rb', line 17 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 |
#listings ⇒ Object
5 6 7 |
# File 'lib/vast_api/attributes.rb', line 5 def listings @listings ||= vast.listings end |