Class: Troo::Decorators::Resource
- Inherits:
-
Object
- Object
- Troo::Decorators::Resource
- Includes:
- Troo::DecoratorHelpers
- Defined in:
- lib/troo/decorators/resource.rb
Direct Known Subclasses
Instance Method Summary collapse
- #as_view ⇒ String
-
#board ⇒ Object
[].
- #comments ⇒ String
- #date ⇒ String
- #default ⇒ String, NilClass
- #description ⇒ String
-
#id ⇒ Object
[].
- #initialize(klass, options = {}) ⇒ Troo::Decorators::Resource constructor
- #last_activity_date ⇒ String
-
#list ⇒ Object
[].
- #members ⇒ String
- #name ⇒ String
- #resource_id ⇒ String
- #resource_title ⇒ String
- #text ⇒ String
- #title ⇒ String
- #username ⇒ String
Methods included from Troo::DecoratorHelpers
Constructor Details
#initialize(klass, options = {}) ⇒ Troo::Decorators::Resource
9 10 11 |
# File 'lib/troo/decorators/resource.rb', line 9 def initialize(klass, = {}) @klass, @options = klass, end |
Instance Method Details
#as_view ⇒ String
101 102 103 |
# File 'lib/troo/decorators/resource.rb', line 101 def as_view Template.parse(self, '/../views/' + type + '.erb') end |
#board ⇒ Object
Returns [].
65 66 67 |
# File 'lib/troo/decorators/resource.rb', line 65 def board klass.board.decorator end |
#comments ⇒ String
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/troo/decorators/resource.rb', line 75 def comments if klass.comments.any? && klass.comments.size > 3 msg = '(There are more comments, use: ' \ "'troo show comments #{klass.short_id}' to view " \ ' all comments.)' [decorated_recent_comments, msg].join("\n") elsif klass.comments.any? decorated_all_comments else 'No comments have been left.' end end |
#date ⇒ String
116 117 118 |
# File 'lib/troo/decorators/resource.rb', line 116 def date Time.parse(klass.date).strftime('%a, %b %d at %H:%M') end |
#default ⇒ String, NilClass
55 56 57 |
# File 'lib/troo/decorators/resource.rb', line 55 def default klass.default? ? '*' : nil end |
#description ⇒ String
48 49 50 51 52 |
# File 'lib/troo/decorators/resource.rb', line 48 def description return 'N/A' if klass.description.nil? || klass.description.empty? Troo::Formatter.wordwrap(klass.description) end |
#id ⇒ Object
Returns [].
43 44 45 |
# File 'lib/troo/decorators/resource.rb', line 43 def id (klass.type == :card) ? klass.short_id : klass.id end |
#last_activity_date ⇒ String
94 95 96 97 98 |
# File 'lib/troo/decorators/resource.rb', line 94 def last_activity_date return 'N/A' unless klass.last_activity_date Time.parse(klass.last_activity_date) .strftime('%a, %b %d at %H:%M') end |
#list ⇒ Object
Returns [].
70 71 72 |
# File 'lib/troo/decorators/resource.rb', line 70 def list klass.list.decorator end |
#members ⇒ String
89 90 91 |
# File 'lib/troo/decorators/resource.rb', line 89 def members Presenters::Member.new(klass).show end |
#name ⇒ String
60 61 62 |
# File 'lib/troo/decorators/resource.rb', line 60 def name (klass.name && klass.name.chomp) || 'N/A' end |
#resource_id ⇒ String
33 34 35 36 37 38 39 40 |
# File 'lib/troo/decorators/resource.rb', line 33 def resource_id if klass.type == :card brackets(Troo::Formatter.highlight( Troo::Wordwrap.this(id), )) else brackets(id) end end |
#resource_title ⇒ String
23 24 25 26 27 28 29 30 |
# File 'lib/troo/decorators/resource.rb', line 23 def resource_title if klass.type == :card Troo::Wordwrap.this(name, prune: true) else Troo::Formatter.highlight( Troo::Wordwrap.this(name, prune: true), ) end end |
#text ⇒ String
111 112 113 |
# File 'lib/troo/decorators/resource.rb', line 111 def text Troo::Formatter.wordwrap(klass.text) end |
#title ⇒ String
14 15 16 17 18 19 20 |
# File 'lib/troo/decorators/resource.rb', line 14 def title [ resource_id, resource_title, default ].compact.join(' ') + "\n" end |
#username ⇒ String
106 107 108 |
# File 'lib/troo/decorators/resource.rb', line 106 def username ['@', klass.member.username].join end |