Class: VastApi::Attributes

Inherits:
Hash
  • Object
show all
Defined in:
lib/vast_api/attributes.rb,
lib/vast_api/attributes/entry.rb

Defined Under Namespace

Classes: Entry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vast) ⇒ Attributes

Returns a new instance of Attributes.



5
6
7
8
9
10
# File 'lib/vast_api/attributes.rb', line 5

def initialize(vast)
  @vast = vast
  @url = "#{@vast.api_url}attributes/-/#{@vast.category}?#{@vast.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/attributes.rb', line 3

def url
  @url
end

#vastObject (readonly)

Returns the value of attribute vast.



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

def vast
  @vast
end

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



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/vast_api/attributes.rb', line 12

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