Class: VastApi::Categories

Inherits:
Hash
  • Object
show all
Defined in:
lib/vast_api/categories.rb,
lib/vast_api/categories/category.rb

Defined Under Namespace

Modules: Category

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vast) ⇒ Categories

Returns a new instance of Categories.



7
8
9
10
11
12
# File 'lib/vast_api/categories.rb', line 7

def initialize(vast)
  @vast = vast
  @url = "#{@vast.api_url}categories?#{@vast.api_query}"
  @xml = Nokogiri::XML(open(@url))
  populate
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/vast_api/categories.rb', line 3

def url
  @url
end

#vastObject (readonly)

Returns the value of attribute vast.



3
4
5
# File 'lib/vast_api/categories.rb', line 3

def vast
  @vast
end

#xmlObject (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



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vast_api/categories.rb', line 14

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