Sha256: e0a74ba24ab2783355163a3e61388d7af0ae603bd137ce83d0a5ffe6dab334a4

Contents?: true

Size: 887 Bytes

Versions: 5

Compression:

Stored size: 887 Bytes

Contents

class Rubyfocus::RankedItem < Rubyfocus::NamedItem
	attr_accessor :rank

	# Ranked items also happen to be contained items
	# Container setting is handled by subclasses - tasks and folders
	idref :container

	# Retrieve a full list of the parents of this item. [0] = immediate parent
	def ancestry
		if container
			[container] + container.ancestry
		else
			[]
		end
	end

	# 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.
	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

	def apply_xml(n)
		super(n)
		conditional_set(:rank, n.at_xpath("xmlns:rank")){ |e| e.inner_html.to_i }
	end

	private
	def inspect_properties
		super + %w(rank)
	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubyfocus-0.5.16 lib/rubyfocus/items/ranked_item.rb
rubyfocus-0.5.15 lib/rubyfocus/items/ranked_item.rb
rubyfocus-0.5.14 lib/rubyfocus/items/ranked_item.rb
rubyfocus-0.5.13 lib/rubyfocus/items/ranked_item.rb
rubyfocus-0.5.12 lib/rubyfocus/items/ranked_item.rb