class Tempo::Model::Project
Attributes
title[RW]
Public Class Methods
current(instance=nil)
click to toggle source
# File lib/tempo/models/project.rb, line 12 def current(instance=nil) @current end
current=(instance)
click to toggle source
# File lib/tempo/models/project.rb, line 16 def current=(instance) if instance.class == self @current = instance else raise ArgumentError end end
include?(title)
click to toggle source
# File lib/tempo/models/project.rb, line 24 def include?(title) return false if index.empty? matches = find_by_title(title) return false if matches.empty? matches.each do |match| return true if match.title == title end false end
new(options={})
click to toggle source
Calls superclass method
Tempo::Model::Composite::new
# File lib/tempo/models/project.rb, line 38 def initialize(options={}) super options @title = options.fetch(:title, "new project") @tags = [] tag options.fetch(:tags, []) current = options.fetch(:current, false) self.class.current = self if current end
Public Instance Methods
current?()
click to toggle source
# File lib/tempo/models/project.rb, line 47 def current? self.class.current == self end
freeze_dry()
click to toggle source
record the active project by adding current = true
Calls superclass method
Tempo::Model::Base#freeze_dry
# File lib/tempo/models/project.rb, line 52 def freeze_dry record = super if self.class.current == self record[:current] = true end record end
tag(tags)
click to toggle source
# File lib/tempo/models/project.rb, line 60 def tag(tags) return unless tags and tags.kind_of? Array tags.each do |tag| tag.split.each {|t| @tags << t if ! @tags.include? t } end @tags.sort! end
to_s()
click to toggle source
# File lib/tempo/models/project.rb, line 75 def to_s puts "id: #{id}, title: #{title}, tags: #{tags}" end
untag(tags)
click to toggle source
# File lib/tempo/models/project.rb, line 68 def untag(tags) return unless tags and tags.kind_of? Array tags.each do |tag| tag.split.each {|t| @tags.delete t } end end