Class: Notes::ConsoleExport
- Inherits:
-
BaseExport
- Object
- BaseExport
- Notes::ConsoleExport
- Defined in:
- lib/notes/export/console_export.rb
Constant Summary collapse
- TOKEN_FIELD_LENGTH =
20
- TAG_FIELD_LENGTH =
25
- DESCRIPTION_FIELD_LENGTH =
50
- DUE_DATE_FIELD_LENGTH =
14
- HEADER =
'+' + '-' * (TOKEN_FIELD_LENGTH + TAG_FIELD_LENGTH + DESCRIPTION_FIELD_LENGTH + DUE_DATE_FIELD_LENGTH + 3) + '+'
Constants inherited from BaseExport
BaseExport::DESCRIPTION, BaseExport::DUE_DATE, BaseExport::TAG, BaseExport::TOKEN
Instance Method Summary collapse
Instance Method Details
#export_note(note_hash) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/notes/export/console_export.rb', line 23 def export_note(note_hash) result = center_in_container(TOKEN_FIELD_LENGTH, note_hash[Options::TOKEN.to_s]) result += center_in_container(TAG_FIELD_LENGTH, (note_hash[Options::TAG.to_s])) result += center_in_container(DESCRIPTION_FIELD_LENGTH, note_hash[Options::DESCRIPTION.to_s]) result += center_in_container(DUE_DATE_FIELD_LENGTH, note_hash[Options::DUE_DATE.to_s]) result += '|' result end |
#export_notes(note_list) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/notes/export/console_export.rb', line 9 def export_notes note_list result = HEADER + "\n" heading = center_in_container(TOKEN_FIELD_LENGTH, TOKEN) + center_in_container(TAG_FIELD_LENGTH, TAG) heading += center_in_container(DESCRIPTION_FIELD_LENGTH, DESCRIPTION) + center_in_container(DUE_DATE_FIELD_LENGTH, DUE_DATE) result += heading + '|' + "\n" result += HEADER + "\n" note_list.each do |note| result += export_note note result += "\n" end result += HEADER + "\n" result end |