Class: NoWhen::Model::Tag

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/nowhen/model/tag.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find(query = {}) ⇒ Object



12
13
14
15
16
17
# File 'lib/nowhen/model/tag.rb', line 12

def self.find(query={})
  {:order => [:created_at.asc]}.each do |k,v|
    query[k] = v unless query.include? k
  end
  self.all query
end

Instance Method Details

#logs(minute = 5) ⇒ Object



19
20
21
22
# File 'lib/nowhen/model/tag.rb', line 19

def logs(minute=5)
  rational = Rational(1, 24*60/minute)
  Log.find :created_at => (self.created_at-rational)..(self.created_at+rational)
end

#to_sObject



24
25
26
# File 'lib/nowhen/model/tag.rb', line 24

def to_s
  "[#{self.what}]\t#{self.created_at.strftime '(%m/%d %a %H:%M:%S)'}"
end