Class: Suc::Reports::Personal
- Inherits:
-
Object
- Object
- Suc::Reports::Personal
- Defined in:
- lib/reports/personal.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#week ⇒ Object
readonly
Returns the value of attribute week.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #export ⇒ Object
- #grouped_by_color ⇒ Object
-
#initialize(year, week, scope = 'person') ⇒ Personal
constructor
A new instance of Personal.
- #print ⇒ Object
Constructor Details
#initialize(year, week, scope = 'person') ⇒ Personal
Returns a new instance of Personal.
9 10 11 12 13 14 15 16 |
# File 'lib/reports/personal.rb', line 9 def initialize(year, week, scope='person') @week = week @year = year resource = '/api/years/%s/weeks/%s/messages' % [year, week] response = RestClient.get(Suc.resource_url(resource).to_s, { params: { scope: scope }, authorization: Suc.token_auth }) @messages = Message.from_json(response) @email = Email.new(self) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/reports/personal.rb', line 7 def body @body end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
7 8 9 |
# File 'lib/reports/personal.rb', line 7 def email @email end |
#week ⇒ Object (readonly)
Returns the value of attribute week.
7 8 9 |
# File 'lib/reports/personal.rb', line 7 def week @week end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
7 8 9 |
# File 'lib/reports/personal.rb', line 7 def year @year end |
Instance Method Details
#export ⇒ Object
29 30 31 |
# File 'lib/reports/personal.rb', line 29 def export email.export end |
#grouped_by_color ⇒ Object
18 19 20 |
# File 'lib/reports/personal.rb', line 18 def grouped_by_color @messages.group_by{|x| x.color}.sort_by{|x| x.first.length} end |
#print ⇒ Object
22 23 24 25 26 27 |
# File 'lib/reports/personal.rb', line 22 def print file = File.read File.join(File.dirname(__FILE__), '../templates/personal_report.erb') template = ERB.new(file, 0, '-<>') @body = template.result(binding) puts @body end |