Class: Place::WorkRecord
- Inherits:
-
Ohm::Model
- Object
- Ohm::Model
- Place::WorkRecord
- Defined in:
- lib/place/work_record.rb
Overview
Each WorkRecord ties a User to a WorkItem, with a time_spent
, date
plus a type
and a comment
Class Attribute Summary collapse
-
.rules ⇒ Object
Returns the value of attribute rules.
Instance Method Summary collapse
-
#retrieve ⇒ Object
Retrieve a specific workrecord data (time_spent, date, user, workitem) + (type, comment).
Class Attribute Details
.rules ⇒ Object
Returns the value of attribute rules.
16 17 18 |
# File 'lib/place/work_record.rb', line 16 def rules @rules end |
Instance Method Details
#retrieve ⇒ Object
Retrieve a specific workrecord data (time_spent, date, user, workitem) + (type, comment)
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/place/work_record.rb', line 26 def retrieve content = IO.readlines(url).join('') doc = Nokogiri::XML(content) self.class.rules.each_pair do |k,v| tmp = doc.xpath(v) case k when 'time_spent' self.send("#{k}=", to_hours(tmp[0].content)) when 'user' self.send("#{k}=", User.find_by_name(tmp[0].content)) else self.send("#{k}=", tmp[0].content) unless tmp[0].nil? end end self.workitem = WorkItem.find_by_wid(File.dirname(self.url).split(/\//).last) Place.logger.info("saved workrecord #{self.url}") self.save end |