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 = 78, from_limit = 16, 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.
190 191 192 193 194 195 196 197 198 199 |
# File 'lib/mournmail/summary.rb', line 190 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.
188 189 190 |
# File 'lib/mournmail/summary.rb', line 188 def cache_id @cache_id end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
186 187 188 |
# File 'lib/mournmail/summary.rb', line 186 def date @date end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
186 187 188 |
# File 'lib/mournmail/summary.rb', line 186 def flags @flags end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
186 187 188 |
# File 'lib/mournmail/summary.rb', line 186 def from @from end |
#replies ⇒ Object (readonly)
Returns the value of attribute replies.
187 188 189 |
# File 'lib/mournmail/summary.rb', line 187 def replies @replies end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
186 187 188 |
# File 'lib/mournmail/summary.rb', line 186 def subject @subject end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
186 187 188 |
# File 'lib/mournmail/summary.rb', line 186 def uid @uid end |
Instance Method Details
#add_reply(reply) ⇒ Object
201 202 203 |
# File 'lib/mournmail/summary.rb', line 201 def add_reply(reply) @replies << reply end |
#delete_reply_if(&block) ⇒ Object
205 206 207 208 209 210 211 212 213 214 |
# File 'lib/mournmail/summary.rb', line 205 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
244 245 246 |
# File 'lib/mournmail/summary.rb', line 244 def flags_char format_flags(@flags) end |
#set_flag(flag, update_server: true) ⇒ Object
227 228 229 230 231 |
# File 'lib/mournmail/summary.rb', line 227 def set_flag(flag, update_server: true) if !@flags.include?(flag) update_flag("+", flag, update_server: update_server) end end |
#to_s(limit = 78, from_limit = 16, level = 0) ⇒ Object
216 217 218 219 220 221 222 223 224 225 |
# File 'lib/mournmail/summary.rb', line 216 def to_s(limit = 78, from_limit = 16, level = 0) @line ||= format_line(limit, from_limit, level) 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
239 240 241 242 |
# File 'lib/mournmail/summary.rb', line 239 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
233 234 235 236 237 |
# File 'lib/mournmail/summary.rb', line 233 def unset_flag(flag, update_server: true) if @flags.include?(flag) update_flag("-", flag, update_server: update_server) end end |