Class: Rubyfocus::RankedItem

Inherits:
NamedItem show all
Defined in:
lib/rubyfocus/items/ranked_item.rb

Direct Known Subclasses

Context, Folder, Task

Instance Attribute Summary collapse

Attributes inherited from NamedItem

#name

Attributes inherited from Item

#added, #document, #id, #modified

Instance Method Summary collapse

Methods inherited from NamedItem

#to_s

Methods inherited from Item

#initialize, #inspect, #to_serial

Methods included from ConditionalExec

#conditional_set

Methods included from IDRef

included

Constructor Details

This class inherits a constructor from Rubyfocus::Item

Instance Attribute Details

#rankObject

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

#ancestryObject

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.

Returns:

  • (Boolean)


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