Class: Mournmail::SummaryItem
- Inherits:
-
Object
- Object
- Mournmail::SummaryItem
- Defined in:
- lib/mournmail/summary.rb
Instance Attribute Summary collapse
-
#cache_id ⇒ Object
Returns the value of attribute cache_id.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#replies ⇒ Object
readonly
Returns the value of attribute replies.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Instance Method Summary collapse
- #add_reply(reply) ⇒ Object
- #delete_reply_if(&block) ⇒ Object
- #flags_char ⇒ Object
-
#initialize(uid, date, from, subject, flags) ⇒ SummaryItem
constructor
A new instance of SummaryItem.
- #set_flag(flag, update_server: true) ⇒ Object
- #to_s(limit = , from_limit = , level = 0) ⇒ Object
- #toggle_flag(flag, update_server: true) ⇒ Object
- #unset_flag(flag, update_server: true) ⇒ Object
Constructor Details
#initialize(uid, date, from, subject, flags) ⇒ SummaryItem
Returns a new instance of SummaryItem.
192 193 194 195 196 197 198 199 200 201 |
# File 'lib/mournmail/summary.rb', line 192 def initialize(uid, date, from, subject, flags) @uid = uid @date = date @from = from @subject = subject @flags = flags @line = nil @replies = [] @cache_id = nil end |
Instance Attribute Details
#cache_id ⇒ Object
Returns the value of attribute cache_id.
190 191 192 |
# File 'lib/mournmail/summary.rb', line 190 def cache_id @cache_id end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
188 189 190 |
# File 'lib/mournmail/summary.rb', line 188 def date @date end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
188 189 190 |
# File 'lib/mournmail/summary.rb', line 188 def flags @flags end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
188 189 190 |
# File 'lib/mournmail/summary.rb', line 188 def from @from end |
#replies ⇒ Object (readonly)
Returns the value of attribute replies.
189 190 191 |
# File 'lib/mournmail/summary.rb', line 189 def replies @replies end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
188 189 190 |
# File 'lib/mournmail/summary.rb', line 188 def subject @subject end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
188 189 190 |
# File 'lib/mournmail/summary.rb', line 188 def uid @uid end |
Instance Method Details
#add_reply(reply) ⇒ Object
203 204 205 |
# File 'lib/mournmail/summary.rb', line 203 def add_reply(reply) @replies << reply end |
#delete_reply_if(&block) ⇒ Object
207 208 209 210 211 212 213 214 215 216 |
# File 'lib/mournmail/summary.rb', line 207 def delete_reply_if(&block) @replies = @replies.flat_map { |reply| reply.delete_reply_if(&block) if yield(reply) reply.replies else [reply] end } end |
#flags_char ⇒ Object
250 251 252 |
# File 'lib/mournmail/summary.rb', line 250 def flags_char format_flags(@flags) end |
#set_flag(flag, update_server: true) ⇒ Object
233 234 235 236 237 |
# File 'lib/mournmail/summary.rb', line 233 def set_flag(flag, update_server: true) if !@flags.include?(flag) update_flag("+", flag, update_server: update_server) end end |
#to_s(limit = , from_limit = , level = 0) ⇒ Object
218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/mournmail/summary.rb', line 218 def to_s(limit = CONFIG[:mournmail_summary_line_limit], from_limit = CONFIG[:mournmail_summary_from_limit], level = 0) if @line.nil? || !CONFIG[:mournmail_summary_use_line_cache] @line = format_line(limit, from_limit, level) end return @line if @replies.empty? s = @line.dup child_level = level + 1 @replies.each do |reply| s << reply.to_s(limit, from_limit, child_level) end s end |
#toggle_flag(flag, update_server: true) ⇒ Object
245 246 247 248 |
# File 'lib/mournmail/summary.rb', line 245 def toggle_flag(flag, update_server: true) sign = @flags.include?(flag) ? "-" : "+" update_flag(sign, flag, update_server: update_server) end |
#unset_flag(flag, update_server: true) ⇒ Object
239 240 241 242 243 |
# File 'lib/mournmail/summary.rb', line 239 def unset_flag(flag, update_server: true) if @flags.include?(flag) update_flag("-", flag, update_server: update_server) end end |