Skip to content

Latest commit

 

History

History
96 lines (63 loc) · 1.68 KB

files.md

File metadata and controls

96 lines (63 loc) · 1.68 KB

Files

{id: files}

Files intro

{id: files-intro}

Read from file (slurp)

{id: read-from-file} {i: read} {i: slurp}

  • Read the content of the whole file
  • Raise exception File::NotFoundError if file does not exist

Read lines into array

{id: read-lines-into-array} {id: read_lines}

Read file line-by-line

{id: read-file-line-by-line} {i: each_line}

Write to file

{id: write-to-file} {i: write}

  • Write the content to the file
  • Raise exception if cannot open file for writing
  • e.g. raise File::NotFoundError if parent directory does not exist

Append to file

{id: append-to-file} {i: append}

  • This is a bug in my code, but it still creates the file with some strange rights ---xr-Sr--

  • The ameba linter will catch this error.

Does file exist?

{id: file-exists} {i: exists?}

Size of file?

{id: size-of-file} {i: empty?} {i: size}

Last Modified date of file?

{id: modified-date-of-file} {i: modification_time}

Counter

{id: counter}

Multi Counter JSON

{id: multi-counter-json} {i: json} {i: from_json} {i: to_json}

Multi Counter YAML

{id: multi-counter-yaml} {i: yaml} {i: from_yaml} {i: to_yaml}