Class: VastApi::Attributes::Entry
- Inherits:
-
Hash
- Object
- Hash
- VastApi::Attributes::Entry
- Defined in:
- lib/vast_api/attributes/entry.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#vast ⇒ Object
readonly
Returns the value of attribute vast.
Instance Method Summary collapse
- #attribute(var_name) ⇒ Object
- #author ⇒ Object
-
#initialize(vast, doc) ⇒ Entry
constructor
A new instance of Entry.
- #updated ⇒ Object
Constructor Details
#initialize(vast, doc) ⇒ Entry
Returns a new instance of Entry.
5 6 7 8 9 10 11 12 |
# File 'lib/vast_api/attributes/entry.rb', line 5 def initialize(vast,doc) @attributes = {} @doc = doc @vast = vast @doc.xpath("v:attribute/v:value").each do |value| self[value["id"]] = { :name => value.content, :count => value["count"] } end end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
4 5 6 |
# File 'lib/vast_api/attributes/entry.rb', line 4 def doc @doc end |
#vast ⇒ Object (readonly)
Returns the value of attribute vast.
4 5 6 |
# File 'lib/vast_api/attributes/entry.rb', line 4 def vast @vast end |
Instance Method Details
#attribute(var_name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/vast_api/attributes/entry.rb', line 14 def attribute(var_name) @attributes[var_name] ||= if %W{author updated}.index(var_name) self.send(var_name) elsif %W{ title id content }.index(var_name) get_var('xmlns:'+var_name) else get_var("v:#{var_name}") end end |
#author ⇒ Object
25 26 27 |
# File 'lib/vast_api/attributes/entry.rb', line 25 def @attributes['author'] ||= get_children(@doc.at_xpath('xmlns:author')) end |
#updated ⇒ Object
29 30 31 |
# File 'lib/vast_api/attributes/entry.rb', line 29 def updated @attributes["updated"] ||= DateTime.strptime(@doc.at_xpath('xmlns:updated').content) end |