Class: Rubyfocus::RankedItem
- Defined in:
- lib/rubyfocus/items/ranked_item.rb
Instance Attribute Summary collapse
-
#rank ⇒ Object
Returns the value of attribute rank.
Attributes inherited from NamedItem
Attributes inherited from Item
#added, #document, #id, #modified
Instance Method Summary collapse
-
#ancestry ⇒ Object
Retrieve a full list of the parents of this item.
- #apply_xml(n) ⇒ Object
-
#contained_within?(object) ⇒ Boolean
Is this item contained within another? You may supply an object, string or integer ID, hash of properties, or proc to run on each item.
Methods inherited from NamedItem
Methods inherited from Item
#initialize, #inspect, #to_serial
Methods included from ConditionalExec
Methods included from IDRef
Constructor Details
This class inherits a constructor from Rubyfocus::Item
Instance Attribute Details
#rank ⇒ Object
Returns the value of attribute rank.
2 3 4 |
# File 'lib/rubyfocus/items/ranked_item.rb', line 2 def rank @rank end |
Instance Method Details
#ancestry ⇒ Object
Retrieve a full list of the parents of this item. [0] = immediate parent
9 10 11 12 13 14 15 |
# File 'lib/rubyfocus/items/ranked_item.rb', line 9 def ancestry if container [container] + container.ancestry else [] end end |
#apply_xml(n) ⇒ Object
27 28 29 30 |
# File 'lib/rubyfocus/items/ranked_item.rb', line 27 def apply_xml(n) super(n) conditional_set(:rank, n.at_xpath("xmlns:rank")){ |e| e.inner_html.to_i } end |
#contained_within?(object) ⇒ Boolean
Is this item contained within another? You may supply an object, string or integer ID, hash of properties, or proc to run on each item.
19 20 21 22 23 24 25 |
# File 'lib/rubyfocus/items/ranked_item.rb', line 19 def contained_within?(object) if [String, Integer, Hash, Proc].include?(object.class) document.find_all(object).any?{ |o| ancestry.include?(o) } else ancestry.include?(object) end end |