Class: InboxFromFile
Constant Summary
Constants included from Status
Status::ACTIVE_STATES, Status::INACTIVE_STATES, Status::STATUS_ORDER, Status::STATUS_SYMBOLS, Status::SYMBOLS_STATUS
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Attributes inherited from Context
Instance Method Summary collapse
- #empty! ⇒ Object
-
#initialize(file_name) ⇒ InboxFromFile
constructor
A new instance of InboxFromFile.
- #read ⇒ Object
-
#write ⇒ Object
log @entries.
Methods inherited from Inbox
Methods inherited from Context
#<<, #delete, #include?, #to_s
Methods included from Status
#active, #directory_name, #inactive, #index, #symbol, #with_status
Constructor Details
#initialize(file_name) ⇒ InboxFromFile
3 4 5 |
# File 'lib/inbox_persistence.rb', line 3 def initialize(file_name) @file_name = file_name end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
2 3 4 |
# File 'lib/inbox_persistence.rb', line 2 def entries @entries end |
Instance Method Details
#empty! ⇒ Object
6 7 8 |
# File 'lib/inbox_persistence.rb', line 6 def empty! @entries = [] end |
#read ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/inbox_persistence.rb', line 9 def read content = File.exists?(@file_name) ? read_and_decode(@file_name):'' @entries = [] content.each_line do |line| line.strip! @entries << line unless line.empty? end #log @entries end |
#write ⇒ Object
log @entries
18 19 20 |
# File 'lib/inbox_persistence.rb', line 18 def write File.open(@file_name,"w") {} if File.exists?(@file_name) if @entries.empty? end |