Class: VastApi::Categories
- Inherits:
-
Hash
- Object
- Hash
- VastApi::Categories
- Defined in:
- lib/vast_api/categories.rb,
lib/vast_api/categories/category.rb
Defined Under Namespace
Modules: Category
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) ⇒ Categories
constructor
A new instance of Categories.
Constructor Details
#initialize(vast) ⇒ Categories
Returns a new instance of Categories.
7 8 9 10 11 12 13 |
# File 'lib/vast_api/categories.rb', line 7 def initialize(vast) @vast = vast @url = "#{@vast.api_url}categories?#{@vast.api_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/categories.rb', line 3 def response @response end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/vast_api/categories.rb', line 3 def url @url end |
#vast ⇒ Object (readonly)
Returns the value of attribute vast.
3 4 5 |
# File 'lib/vast_api/categories.rb', line 3 def vast @vast end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
3 4 5 |
# File 'lib/vast_api/categories.rb', line 3 def xml @xml end |
Instance Method Details
#attr(var_name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vast_api/categories.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 |